Lely core libraries  2.2.5
fiber.h
Go to the documentation of this file.
1 
33 #ifndef LELY_UTIL_FIBER_H_
34 #define LELY_UTIL_FIBER_H_
35 
36 #include <lely/features.h>
37 
38 #include <stddef.h>
39 
41 typedef struct fiber fiber_t;
42 
47 #define FIBER_SAVE_MASK 0x1
48 
52 #define FIBER_SAVE_FENV 0x2
53 
58 #define FIBER_SAVE_ERROR 0x4
59 
64 #if _POSIX_C_SOURCE >= 200112L
65 #define FIBER_SAVE_ALL (FIBER_SAVE_MASK | FIBER_SAVE_FENV | FIBER_SAVE_ERROR)
66 #else
67 #define FIBER_SAVE_ALL (FIBER_SAVE_FENV | FIBER_SAVE_ERROR)
68 #endif
69 
77 #define FIBER_GUARD_STACK 0x8
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
96 typedef fiber_t *fiber_func_t(fiber_t *fiber, void *arg);
97 
114 int fiber_thrd_init(int flags);
115 
121 void fiber_thrd_fini(void);
122 
142 fiber_t *fiber_create(fiber_func_t *func, void *arg, int flags,
143  size_t data_size, size_t stack_size);
144 
151 
157 void *fiber_data(const fiber_t *fiber);
158 
161 
181 fiber_t *fiber_resume_with(fiber_t *fiber, fiber_func_t *func, void *arg);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif // !LELY_UTIL_FIBER_H_
features.h
fiber_create
fiber_t * fiber_create(fiber_func_t *func, void *arg, int flags, size_t data_size, size_t stack_size)
Creates a new fiber, allocates a stack and sets up a calling environment to begin executing the speci...
Definition: fiber-sjlj.c:152
fiber
Definition: fiber-sjlj.c:66
fiber_data
void * fiber_data(const fiber_t *fiber)
Returns a pointer to the data region of the specified fiber, or of the calling fiber if fiber is NULL...
Definition: fiber-sjlj.c:314
fiber_destroy
void fiber_destroy(fiber_t *fiber)
Destroys the specified fiber.
Definition: fiber-sjlj.c:299
fiber_thrd_fini
void fiber_thrd_fini(void)
Finalizes the fiber associated with the calling thread.
Definition: fiber-sjlj.c:135
fiber_resume
fiber_t * fiber_resume(fiber_t *fiber)
Equivalent to fiber_resume_with(fiber, NULL, NULL).
Definition: fiber-sjlj.c:322
fiber_func_t
fiber_t * fiber_func_t(fiber_t *fiber, void *arg)
The type of the function executed by a fiber.
Definition: fiber.h:96
fiber_resume_with
fiber_t * fiber_resume_with(fiber_t *fiber, fiber_func_t *func, void *arg)
Suspends the calling fiber and resumes the specified fiber, optionally executing a function before re...
Definition: fiber-sjlj.c:334
fiber_thrd_init
int fiber_thrd_init(int flags)
Initializes the fiber associated with the calling thread.
Definition: fiber-sjlj.c:108
stddef.h