Janet 1.35.0-0d9e999 Documentation
(Other Versions:
1.34.0
1.31.0
1.29.1
1.28.0
1.27.0
1.26.0
1.25.1
1.24.0
1.23.0
1.22.0
1.21.0
1.20.0
1.19.0
1.18.1
1.17.1
1.16.1
1.15.0
1.13.1
1.12.2
1.11.1
1.10.1
1.9.1
1.8.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.1
)
Fiber Module
Index
fiber/can-resume? fiber/current fiber/getenv fiber/last-value fiber/maxstack fiber/new fiber/root fiber/setenv fiber/setmaxstack fiber/status
fiber/can-resume? cfunction source
(fiber/can-resume? fiber) Check if a fiber is finished and cannot be resumed.Community Examples
fiber/current cfunction source
(fiber/current) Returns the currently running fiber.Community Examples
fiber/getenv cfunction source
(fiber/getenv fiber) Gets the environment for a fiber. Returns nil if no such table is set yet.Community Examples
fiber/last-value cfunction source
(fiber/last-value fiber) Get the last value returned or signaled from the fiber.Community Examples
fiber/maxstack cfunction source
(fiber/maxstack fib) Gets the maximum stack size in janet values allowed for a fiber. While memory for the fiber's stack is not allocated up front, the fiber will not allocated more than this amount and will throw a stack-overflow error if more memory is needed.Community Examples
fiber/new cfunction source
(fiber/new func &opt sigmask env) Create a new fiber with function body func. Can optionally take a set of signals `sigmask` to capture from child fibers, and an environment table `env`. The mask is specified as a keyword where each character is used to indicate a signal to block. If the ev module is enabled, and this fiber is used as an argument to `ev/go`, these "blocked" signals will result in messages being sent to the supervisor channel. The default sigmask is :y. For example, (fiber/new myfun :e123) blocks error signals and user signals 1, 2 and 3. The signals are as follows: * :a - block all signals * :d - block debug signals * :e - block error signals * :t - block termination signals: error + user[0-4] * :u - block user signals * :y - block yield signals * :w - block await signals (user9) * :r - block interrupt signals (user8) * :0-9 - block a specific user signal The sigmask argument also can take environment flags. If any mutually exclusive flags are present, the last flag takes precedence. * :i - inherit the environment from the current fiber * :p - the environment table's prototype is the current environment tableCommunity Examples
fiber/root cfunction source
(fiber/root) Returns the current root fiber. The root fiber is the oldest ancestor that does not have a parent.Community Examples
fiber/setenv cfunction source
(fiber/setenv fiber table) Sets the environment table for a fiber. Set to nil to remove the current environment.Community Examples
fiber/setmaxstack cfunction source
(fiber/setmaxstack fib maxstack) Sets the maximum stack size in janet values for a fiber. By default, the maximum stack size is usually 8192.Community Examples
fiber/status cfunction source
(fiber/status fib) Get the status of a fiber. The status will be one of: * :dead - the fiber has finished * :error - the fiber has errored out * :debug - the fiber is suspended in debug mode * :pending - the fiber has been yielded * :user(0-7) - the fiber is suspended by a user signal * :interrupted - the fiber was interrupted * :suspended - the fiber is waiting to be resumed by the scheduler * :alive - the fiber is currently running and cannot be resumed * :new - the fiber has just been created and not yet runCommunity Examples