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
41typedef 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
88extern "C" {
89#endif
90
107
124int fiber_thrd_init(int flags);
125
133void fiber_thrd_fini(void);
134
155 size_t data_size, size_t stack_size);
156
163
169void *fiber_data(const fiber_t *fiber);
170
173
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif // !LELY_UTIL_FIBER_H_
This header file is part of the Lely libraries; it contains the compiler feature definitions.
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
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
int fiber_thrd_init(int flags)
Initializes the fiber associated with the calling thread.
Definition: fiber.c:210
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_t * fiber_func_t(fiber_t *fiber, void *arg)
The type of the function executed by a fiber.
Definition: fiber.h:106
void fiber_thrd_fini(void)
Finalizes the fiber associated with the calling thread.
Definition: fiber.c:242
fiber_t * fiber_resume(fiber_t *fiber)
Equivalent to fiber_resume_with(fiber, NULL, NULL).
Definition: fiber.c:424
void fiber_destroy(fiber_t *fiber)
Destroys the specified fiber.
Definition: fiber.c:395
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
A fiber.
Definition: fiber.c:130
int flags
The flags provided to fiber_create().
Definition: fiber.c:136
void * arg
The second argument supplied to func.
Definition: fiber.c:134
fiber_func_t * func
A pointer to the function to be executed in the fiber.
Definition: fiber.c:132