42 for (
int i = 0;; i++) {
45 printf(
"worker: sleep cancelled after %d rounds, winding down\n", i);
48 printf(
"worker: round %d\n", i);
59 printf(
"controller: draining\n");
72 printf(
"run returned; drain converged\n");
static srn_fiber_result_t controller(srn_context_t *ctx, void *arg)
static srn_fiber_result_t controller(srn_context_t *ctx, void *arg)
static srn_fiber_result_t worker_loop(srn_context_t *ctx, 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.
srn_error_t * srn_fiber_sleep_ms(uint64_t duration_ms)
Suspend the calling fiber for at least duration_ms miliseconds, letting its worker run other fibers m...
The fiber facing IO API: blocking looking calls a fiber uses to do IO.
#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_sched_drain(srn_scheduler_t *sched)
Ask a running scheduler to wind down gracefully.
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...
A runtime error, a tag classifying the failure and a human-readable message.