tur/fiber

stdlib/fiber.tur
defn

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.

fnzero-argument function pointer to run as the fiber body
stack-sizerequested stack size in bytes; 0 uses the default size

Since: Phase T21-C

defn

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.

ffiber handle returned by fiber-new
argvalue passed to the fiber as the resume argument

Since: Phase T21-C

defn

fiber-yield

(fiber-yield [value :int] :nil)

suspend the current fiber and return a value to its caller.

valueint64_t value to hand back to the fiber-resume caller

Since: Phase T21-C

defn

fiber-done?

(fiber-done? [f :ptr<void>] :int)

check whether a fiber has run to completion.

ffiber handle returned by fiber-new

Since: Phase T21-C

defn

fiber-arg

(fiber-arg [f :ptr<void>] :int)

retrieve the most recent argument value passed to a fiber via fiber-resume.

ffiber handle returned by fiber-new

Since: Phase T21-C

defn

fiber-free

(fiber-free [f :ptr<void>] :nil)

release all memory associated with a fiber.

ffiber handle returned by fiber-new

Since: Phase T21-C

defn

fiber-local-get

(fiber-local-get [f :ptr<void> key :int] :int)

retrieve a fiber-local value by key from a specific fiber.

ffiber handle returned by fiber-new
keyint64_t key identifying the slot

Since: Phase T21

defn

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.

ffiber handle returned by fiber-new
keyint64_t key identifying the slot
valueint64_t value to store

Since: Phase T21

defn

fiber-local-current-get

(fiber-local-current-get [key :int] :int)

retrieve a fiber-local value by key from the currently running fiber.

keyint64_t key identifying the slot

Since: Phase T21

defn

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.

keyint64_t key identifying the slot
valueint64_t value to store

Since: Phase T21

defn

scheduler-yield!

(scheduler-yield! :nil)

yield the current fiber back to the scheduler, re-enqueueing it for the next turn.

Since: Phase T21

defn

scheduler-park!

(scheduler-park! :nil)

park the current fiber, suspending it without re-enqueueing.

Since: Phase T21

defn

scheduler-unpark!

(scheduler-unpark! [f :ptr<void>] :nil)

unpark a specific fiber and add it back to the scheduler run queue.

ffiber handle to unpark

Since: Phase T21

defn

async-sleep

(async-sleep [ms :int] :nil)

sleep for approximately ms milliseconds without blocking the OS thread.

msduration in milliseconds; values <= 0 return immediately

Since: Phase T24

defn

fiber-thread-id

(fiber-thread-id :int)

return an integer identifier for the OS thread running the current fiber.

Since: Phase T23