Zth (libzth)
Loading...
Searching...
No Matches
init.cpp File Reference
#include <libzth/init.h>
#include <libzth/async.h>
#include <libzth/config.h>
#include <libzth/util.h>
#include <libzth/worker.h>

Go to the source code of this file.

Functions

void zth_init ()
 Perform one-time global initialization of the Zth library.
 
int zth_run (void(fiber)(void *), void *arg)
 Start Zth given the given fiber function.
 
int zth_main (int argc, char **argv)
 Default main function that runs main_fiber.
 

Variables

struct zth_init_entry const * zth_init_head = nullptr
 
struct zth_init_entryzth_init_tail = nullptr
 

Function Documentation

◆ zth_init()

void zth_init ( )

Perform one-time global initialization of the Zth library.

Initialization is only done once. It is safe to call it multiple times.

The initialization sequence is initialized by ZTH_INIT_CALL() and processed in the same order as normal static initializers are executed.

Definition at line 38 of file init.cpp.

◆ zth_main()

int zth_main ( int  argc,
char **  argv 
)

Default main function that runs main_fiber.

Unless main() is defined in the application, this function is called by the default-provided weak main().

Definition at line 104 of file init.cpp.

◆ zth_run()

int zth_run ( void(fiber)(void *)  ,
void *  arg 
)

Start Zth given the given fiber function.

It can be used instead of zth_main() or main(). In contrast, this function does not call zth_preinit() and zth_postdeinit().

Returns
0 when finished the fiber successfully, otherwise an errno

Definition at line 64 of file init.cpp.

Variable Documentation

◆ zth_init_head

struct zth_init_entry const* zth_init_head = nullptr

Definition at line 15 of file init.cpp.

◆ zth_init_tail

struct zth_init_entry* zth_init_tail = nullptr

Definition at line 17 of file init.cpp.