Lely core libraries  2.3.4
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 #if !_WIN32 && defined(__NEWLIB__)
66 #define FIBER_SAVE_ALL (FIBER_SAVE_MASK | FIBER_SAVE_ERROR)
67 #else
68 #define FIBER_SAVE_ALL (FIBER_SAVE_MASK | FIBER_SAVE_FENV | FIBER_SAVE_ERROR)
69 #endif
70 #else
71 #if !_WIN32 && defined(__NEWLIB__)
72 #define FIBER_SAVE_ALL FIBER_SAVE_ERROR
73 #else
74 #define FIBER_SAVE_ALL (FIBER_SAVE_FENV | FIBER_SAVE_ERROR)
75 #endif
76 #endif
77 
85 #define FIBER_GUARD_STACK 0x8
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
107 
124 int fiber_thrd_init(int flags);
125 
133 void fiber_thrd_fini(void);
134 
155  size_t data_size, size_t stack_size);
156 
163 
169 void *fiber_data(const fiber_t *fiber);
170 
173 
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif // !LELY_UTIL_FIBER_H_
features.h
fiber
A fiber.
Definition: fiber.c:130
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.c:260
fiber::flags
int flags
The flags provided to fiber_create().
Definition: fiber.c:136
fiber_thrd_init
int fiber_thrd_init(int flags)
Initializes the fiber associated with the calling thread.
Definition: fiber.c:210
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:106
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.c:430
fiber_resume
fiber_t * fiber_resume(fiber_t *fiber)
Equivalent to fiber_resume_with(fiber, NULL, NULL).
Definition: fiber.c:424
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.c:416
fiber::func
fiber_func_t * func
A pointer to the function to be executed in the fiber.
Definition: fiber.c:132
fiber_destroy
void fiber_destroy(fiber_t *fiber)
Destroys the specified fiber.
Definition: fiber.c:395
fiber::arg
void * arg
The second argument supplied to func.
Definition: fiber.c:134
stddef.h
fiber_thrd_fini
void fiber_thrd_fini(void)
Finalizes the fiber associated with the calling thread.
Definition: fiber.c:242