Lely core libraries 2.3.4
fiber_exec.h
Go to the documentation of this file.
1
37#ifndef LELY_EV_FIBER_EXEC_H_
38#define LELY_EV_FIBER_EXEC_H_
39
40#include <lely/ev/future.h>
41#include <lely/util/fiber.h>
42
43enum {
63};
64
65enum {
75};
76
82typedef struct {
83 void *_impl;
85
92typedef struct {
93 void *_impl;
95
96#ifdef __cplusplus
97extern "C" {
98#endif
99
123int ev_fiber_thrd_init(int flags, size_t stack_size, size_t max_unused);
124
130void ev_fiber_thrd_fini(void);
131
132void *ev_fiber_exec_alloc(void);
133void ev_fiber_exec_free(void *ptr);
134ev_exec_t *ev_fiber_exec_init(ev_exec_t *exec, ev_exec_t *inner_exec);
135void ev_fiber_exec_fini(ev_exec_t *exec);
136
149
157
160
168void ev_fiber_await(ev_future_t *future);
169
188int ev_fiber_mtx_init(ev_fiber_mtx_t *mtx, int type);
189
195
208
222
233
245
252
261
271
286
287#ifdef __cplusplus
288}
289#endif
290
291#endif // !LELY_EV_FIBER_EXEC_H_
This header file is part of the utilities library; it contains the fiber declarations.
int ev_fiber_mtx_lock(ev_fiber_mtx_t *mtx)
Suspends the currently running fiber until it locks the fiber mutex at mtx.
Definition: fiber_exec.c:428
void ev_fiber_thrd_fini(void)
Finalizes the calling thread and prevents further use by fiber executors.
Definition: fiber_exec.c:232
int ev_fiber_mtx_init(ev_fiber_mtx_t *mtx, int type)
Creates a fiber mutex object with properties indicated by type, which must have one of the four value...
Definition: fiber_exec.c:378
int ev_fiber_thrd_init(int flags, size_t stack_size, size_t max_unused)
Initializes the calling thread for use by fiber executors.
Definition: fiber_exec.c:206
int ev_fiber_mtx_unlock(ev_fiber_mtx_t *mtx)
Unlocks the fiber mutex at mtx.
Definition: fiber_exec.c:525
void ev_fiber_cnd_destroy(ev_fiber_cnd_t *cond)
Releases all resources used by the fiber condition variable at cond.
Definition: fiber_exec.c:590
void ev_fiber_mtx_destroy(ev_fiber_mtx_t *mtx)
Releases any resources used by the fiber mutex at mtx.
Definition: fiber_exec.c:411
int ev_fiber_cnd_signal(ev_fiber_cnd_t *cond)
Unblocks one of the fibers that are blocked on the fiber condition variable at cond at the time of th...
Definition: fiber_exec.c:606
int ev_fiber_cnd_broadcast(ev_fiber_cnd_t *cond)
Unblocks all of the fibers that are blocked on the fiber condition variable at cond at the time of th...
Definition: fiber_exec.c:627
int ev_fiber_cnd_init(ev_fiber_cnd_t *cond)
Creates a fiber condition variable.
Definition: fiber_exec.c:566
void ev_fiber_exec_destroy(ev_exec_t *exec)
Destroys a fiber executor.
Definition: fiber_exec.c:352
@ ev_fiber_nomem
Indicates that the requested operation failed because it was unable to allocate memory.
Definition: fiber_exec.h:62
@ ev_fiber_busy
Indicates that the requested operation failed because a resource requested by a test and return funct...
Definition: fiber_exec.h:57
@ ev_fiber_error
Indicates that the requested operation failed.
Definition: fiber_exec.h:47
@ ev_fiber_success
Indicates that the requested operation succeeded.
Definition: fiber_exec.h:45
@ ev_fiber_timedout
Indicates that the time specified in the call was reached without acquiring the requested resource.
Definition: fiber_exec.h:52
void ev_fiber_await(ev_future_t *future)
Suspends a currently running fiber until the specified future becomes ready (or is cancelled).
Definition: fiber_exec.c:369
int ev_fiber_cnd_wait(ev_fiber_cnd_t *cond, ev_fiber_mtx_t *mtx)
Atomically unlocks the fiber mutex at mtx and endeavors to block until the fiber condition variable a...
Definition: fiber_exec.c:652
int ev_fiber_mtx_trylock(ev_fiber_mtx_t *mtx)
Endeavors to lock the fiber mutex at mtx.
Definition: fiber_exec.c:476
@ ev_fiber_mtx_plain
A fiber mutex type that supports neither timeout nor recursive locking.
Definition: fiber_exec.h:70
@ ev_fiber_mtx_recursive
A fiber mutex type that supports recursive locking.
Definition: fiber_exec.h:74
@ ev_fiber_mtx_timed
A fiber mutex type that supports timeout (currently not supported).
Definition: fiber_exec.h:72
ev_exec_t * ev_fiber_exec_create(ev_exec_t *inner_exec)
Creates a fiber executor.
Definition: fiber_exec.c:325
ev_exec_t * ev_fiber_exec_get_inner_exec(const ev_exec_t *exec)
Returns a pointer to the inner executor of a fiber executor.
Definition: fiber_exec.c:361
This header file is part of the event library; it contains the futures and promises declarations.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
A synchronization primitive (similar to the standard C11 condition variable) that can be used to bloc...
Definition: fiber_exec.h:92
A synchronization primitive (similar to the standard C11 mutex) that can be used to protect shared da...
Definition: fiber_exec.h:82
A future.
Definition: future.c:66