65 printf(
"consumer: waiting for a value\n");
67 printf(
"consumer: received %d\n",
mailbox.value);
76 printf(
"producer: put %d in the mailbox\n",
mailbox.value);
78 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_fiber_t * srn_fiber_spawn(srn_context_t *ctx, srn_fiber_entry_t entry, void *arg)
Make and schedule a fiber with every default, the engine's scheduler, the configured stack size,...
void * srn_fiber_result_t
What a fiber's entry produces, type-erased.
#define SERENE_RUNTIME_SHUTDOWN(engine)
Tear down what SERENE_RUNTIME_INIT brought up, in reverse order, the engine (reactor,...
#define SERENE_RUNTIME_INIT_WITH_SCHED(engine, sched, config)
SERENE_RUNTIME_INIT plus a sched variable bound to the engine's scheduler, which every run and fiber ...
void srn_fiber_ready(srn_fiber_t *fiber)
Mark a suspended fiber runnable again, waking it when the event it awaited occurs.
void srn_sched_run(srn_scheduler_t *sched, size_t 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...