Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
runtime.c File Reference
#include "serene/runtime.h"
Include dependency graph for runtime.c:

Go to the source code of this file.

Data Structures

struct  srn_main_args_t

Typedefs

typedef struct srn_main_args_t srn_main_args_t

Functions

static srn_fiber_result_t main_fiber_wrapper (srn_context_t *ctx, void *args)
int srn_run_fiber_main (srn_main_t m, int argc, char *argv[])

Typedef Documentation

◆ srn_main_args_t

typedef struct srn_main_args_t srn_main_args_t

Function Documentation

◆ main_fiber_wrapper()

srn_fiber_result_t main_fiber_wrapper ( srn_context_t * ctx,
void * args )
static

Definition at line 28 of file runtime.c.

28 {
29
30 srn_main_args_t *main_args = args;
31 main_args->out = main_args->main_f(ctx, main_args->argc, main_args->argv);
32 return nullptr;
33}
va_list args
Definition acutest.h:876
srn_main_t main_f
Definition runtime.c:22
char ** argv
Definition runtime.c:25
Here is the caller graph for this function:

◆ srn_run_fiber_main()

int srn_run_fiber_main ( srn_main_t m,
int argc,
char * argv[] )

Definition at line 35 of file runtime.c.

35 {
36 SERENE_RUNTIME_INIT_WITH_SCHED(engine, sched, nullptr);
37 srn_context_t *ctx = srn_context_make(engine);
38
40 .main_f = m,
41 .out = 0,
42 .argc = argc,
43 .argv = argv,
44
45 };
46
47 SRN_TRACEPOINT(serene_main_start);
49 srn_sched_run(sched, 0);
50 SRN_TRACEPOINT(serene_main_end);
51
54 return args.out;
55}
srn_context_t * srn_context_make(srn_engine_t *engine)
Make an empty context, by allocating a new memory block.
Definition context.c:39
int srn_context_release(srn_context_t *ctx)
Definition context.c:64
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,...
Definition fiber.c:245
static srn_fiber_result_t main_fiber_wrapper(srn_context_t *ctx, void *args)
Definition runtime.c:28
#define SERENE_RUNTIME_SHUTDOWN(engine)
Tear down what SERENE_RUNTIME_INIT brought up, in reverse order, the engine (reactor,...
Definition runtime.h:58
#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 ...
Definition runtime.h:46
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...
Definition scheduler.c:875
#define SRN_TRACEPOINT(name,...)
Placement matters.
Definition trace.h:79
Here is the call graph for this function: