70 printf(
"consumer: waiting for a value\n");
72 printf(
"consumer: received %d\n",
mailbox.value);
81 printf(
"producer: put %d in the mailbox\n",
mailbox.value);
83 if (
mailbox.waiter !=
nullptr) {
static srn_fiber_result_t producer(srn_context_t *ctx, void *arg)
static srn_fiber_result_t consumer(srn_context_t *ctx, void *arg)
static bool park_on_empty(srn_fiber_t *self, void *arg)
srn_context_t * srn_context_make(srn_engine_t *engine)
Make an empty context, by allocating a new memory block.
int srn_context_release(srn_context_t *ctx)
srn_mm_t * srn_mm_init()
Initialize the memory manager, this function will panic on error.
void srn_mm_shutdown(srn_mm_t *mm)
Shut down the memory manager and release the resources.
srn_engine_t * srn_engine_make(srn_mm_t *mm)
void srn_engine_shutdown(srn_engine_t *engine)
srn_fiber_t * srn_fiber_make(srn_context_t *ctx, srn_scheduler_t *sched, srn_fiber_entry_t entry, void *arg, size_t stack_size)
Create a fiber that will run entry(ctx, arg).
AI Generated (🤦) Fiber subsystem overview.
void * srn_fiber_result_t
void srn_fiber_ready(srn_fiber_t *fiber)
Mark a suspended fiber runnable again.
void srn_sched_run(srn_scheduler_t *sched, int nworkers)
Run the scheduler with nworkers os threads draining it, returning once the pool goes quiescent (every...
void srn_fiber_suspend(srn_fiber_park_fn commit, void *arg)
A suspended fiber is on no scheduler queue, and the scheduler does not track what it waits on – whoev...
Engine is a structure to own the long living and main pieces of the compiler.
srn_scheduler_t * scheduler
The fiber scheduler, set by srn_sched_init.
Main memory manager structure that will own all the allocated blocks and data.