#include <fiber.h>
Definition at line 268 of file fiber.h.
◆ arg
◆ ctx
◆ entry
◆ fiber_ctx
◆ link
Intrusive link threading this fiber onto one of the scheduler's singly-linked lists (the ready run queue, or a wait queue) without a separate node allocation, the next pointer lives in the fiber itself.
A fiber belongs to at most one such list at a time, so one link suffices.
Definition at line 307 of file fiber.h.
◆ name
Debug name, the caller's choice copied at creation, or autogenerated when the caller passed none (see srn_fiber_autoname).
srn_fiber_init_thread names loop fibers "thread". Embedded so the name shares the fiber's lifetime with no separate allocation.
Definition at line 333 of file fiber.h.
◆ park_arg
| void* srn_fiber_t::park_arg |
◆ park_commit
While this fiber is suspending, the commit the worker routine runs once the fiber is off the stack, to publish it to its waker (see srn_fiber_suspend).
Valid only across that one suspend hand-off.
Definition at line 288 of file fiber.h.
◆ reg_next
◆ reg_prev
Registry links.
The scheduler keeps every live fiber on one doubly linked list through these pointers. It is different from link. link says where a fiber sits in the run order, the registry says the fiber exists at all. A fiber joins the list when it is created and leaves when it is reaped, in whatever state it is in between – including SUSPENDED, which sits on no queue.
This is how the scheduler accounts for, cleans up, and (later) cancels its fibers. Doubly linked so reaping can unlink from the middle in O(1).
Definition at line 326 of file fiber.h.
◆ result
Set when state reaches SRN_FIBER_DONE.
Type-erased (see srn_fiber_result_t), the caller interprets it.
Definition at line 283 of file fiber.h.
◆ stack
◆ state
The lifecycle state.
Atomic because a waker may run on a different os thread than the worker running the fiber. srn_fiber_ready flips SUSPENDED to READY with a CAS while the worker running the fiber reads and writes the same field. Making it atomic keeps every access whole, so a read can never see an inconsistent value.
Definition at line 277 of file fiber.h.
◆ waiters
Head of the list of fibers blocked in srn_fiber_wait_for on this fiber.
They are threaded through their own link (a waiter is suspended, so off the ready queue, and its link is free). When this fiber reaches DONE the worker routine wakes them all.
Definition at line 313 of file fiber.h.
The documentation for this struct was generated from the following file: