tur/fiber
fiber-new
(fiber-new [fn :ptr<void> stack-size :int] :ptr<void>)
create a new fiber from a function pointer and an optional stack size.
| fn | zero-argument function pointer to run as the fiber body | |
| stack-size | requested stack size in bytes; 0 uses the default size |
Since: Phase T21-C
fiber-resume
(fiber-resume [f :ptr<void> arg :int] :int)
resume a suspended fiber, passing it a value, and return the yielded or final value.
| f | fiber handle returned by fiber-new | |
| arg | value passed to the fiber as the resume argument |
Since: Phase T21-C
fiber-yield
(fiber-yield [value :int] :nil)
suspend the current fiber and return a value to its caller.
| value | int64_t value to hand back to the fiber-resume caller |
Since: Phase T21-C
fiber-done?
(fiber-done? [f :ptr<void>] :int)
check whether a fiber has run to completion.
| f | fiber handle returned by fiber-new |
Since: Phase T21-C
fiber-arg
(fiber-arg [f :ptr<void>] :int)
retrieve the most recent argument value passed to a fiber via fiber-resume.
| f | fiber handle returned by fiber-new |
Since: Phase T21-C
fiber-free
(fiber-free [f :ptr<void>] :nil)
release all memory associated with a fiber.
| f | fiber handle returned by fiber-new |
Since: Phase T21-C
fiber-local-get
(fiber-local-get [f :ptr<void> key :int] :int)
retrieve a fiber-local value by key from a specific fiber.
| f | fiber handle returned by fiber-new | |
| key | int64_t key identifying the slot |
Since: Phase T21
fiber-local-set!
(fiber-local-set! [f :ptr<void> key :int value :int] :nil)
store a fiber-local value by key in a specific fiber.
| f | fiber handle returned by fiber-new | |
| key | int64_t key identifying the slot | |
| value | int64_t value to store |
Since: Phase T21
fiber-local-current-get
(fiber-local-current-get [key :int] :int)
retrieve a fiber-local value by key from the currently running fiber.
| key | int64_t key identifying the slot |
Since: Phase T21
fiber-local-current-set!
(fiber-local-current-set! [key :int value :int] :nil)
store a fiber-local value by key in the currently running fiber.
| key | int64_t key identifying the slot | |
| value | int64_t value to store |
Since: Phase T21
scheduler-yield!
(scheduler-yield! :nil)
yield the current fiber back to the scheduler, re-enqueueing it for the next turn.
Since: Phase T21
scheduler-park!
(scheduler-park! :nil)
park the current fiber, suspending it without re-enqueueing.
Since: Phase T21
scheduler-unpark!
(scheduler-unpark! [f :ptr<void>] :nil)
unpark a specific fiber and add it back to the scheduler run queue.
| f | fiber handle to unpark |
Since: Phase T21
async-sleep
(async-sleep [ms :int] :nil)
sleep for approximately ms milliseconds without blocking the OS thread.
| ms | duration in milliseconds; values <= 0 return immediately |
Since: Phase T24
fiber-thread-id
(fiber-thread-id :int)
return an integer identifier for the OS thread running the current fiber.
Since: Phase T23