Lely core libraries 2.3.4
future.h
Go to the documentation of this file.
1
27#ifndef LELY_EV_FUTURE_H_
28#define LELY_EV_FUTURE_H_
29
30#include <lely/ev/ev.h>
31
32#include <stdarg.h>
33#include <stddef.h>
34
40typedef struct ev_promise ev_promise_t;
41
43typedef struct ev_future ev_future_t;
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
55typedef void ev_promise_dtor_t(void *ptr);
56
71
81
91void ev_promise_release(ev_promise_t *promise);
92
99int ev_promise_is_unique(const ev_promise_t *promise);
100
102void *ev_promise_data(const ev_promise_t *promise);
103
119int ev_promise_set(ev_promise_t *promise, void *value);
120
129
138void ev_promise_set_release(ev_promise_t *promise, void *value);
139
142
152
161void ev_future_release(ev_future_t *future);
162
169int ev_future_is_unique(const ev_future_t *future);
170
179int ev_future_is_ready(const ev_future_t *future);
180
191void *ev_future_get(const ev_future_t *future);
192
200void ev_future_submit(ev_future_t *future, struct ev_task *task);
201
212size_t ev_future_cancel(ev_future_t *future, struct ev_task *task);
213
223size_t ev_future_abort(ev_future_t *future, struct ev_task *task);
224
231
237 ev_exec_t *exec, ev_future_t *future, va_list ap);
238
261 ev_exec_t *exec, size_t n, ev_future_t *const *futures);
262
269
275 ev_exec_t *exec, ev_future_t *future, va_list ap);
276
298 ev_exec_t *exec, size_t n, ev_future_t *const *futures);
299
300#ifdef __cplusplus
301}
302#endif
303
304#endif // !LELY_EV_FUTURE_H_
ev_promise_t * ev_promise_acquire(ev_promise_t *promise)
Acquires a reference to a promise.
Definition future.c:181
void ev_promise_dtor_t(void *ptr)
The type of the function used to destroy (but not free) the shared state of a promise once the last r...
Definition future.h:55
int ev_future_is_unique(const ev_future_t *future)
Returns 1 if future is the only reference to the future and no references to its associated promise a...
Definition future.c:335
void ev_promise_release(ev_promise_t *promise)
Releases a reference to a promise.
Definition future.c:198
ev_future_t * ev_promise_get_future(ev_promise_t *promise)
Returns (a reference to) a future associated with the specified promise.
Definition future.c:312
int ev_promise_is_unique(const ev_promise_t *promise)
Returns 1 if promise is the only reference to the promise and no references to its associated future ...
Definition future.c:221
size_t ev_future_abort(ev_future_t *future, struct ev_task *task)
Aborts the specified task submitted with ev_future_submit(), if it has not yet been scheduled for exe...
Definition future.c:404
size_t ev_future_cancel(ev_future_t *future, struct ev_task *task)
Cancels the specified task submitted with ev_future_submit(), if it has not yet been scheduled for ex...
Definition future.c:391
int ev_promise_set(ev_promise_t *promise, void *value)
Satiesfies a promise, if it was not aready satisfied, and stores the specified value for retrieval by...
Definition future.c:242
ev_future_t * ev_future_when_all_v(ev_exec_t *exec, ev_future_t *future, va_list ap)
Equivalent to ev_future_when_all(), except that it accepts a va_list instead of a variable number of ...
Definition future.c:427
void ev_promise_set_release(ev_promise_t *promise, void *value)
Satisfies a promise prepared by ev_promise_set_acquire(), and stores the specified value for retrieva...
Definition future.c:275
ev_future_t * ev_future_when_any_n(ev_exec_t *exec, size_t n, ev_future_t *const *futures)
Creates a future that becomes ready when at least one of the input futures becomes ready or is abando...
Definition future.c:500
void * ev_promise_data(const ev_promise_t *promise)
Returns a pointer to the shared state of a promise.
Definition future.c:236
ev_future_t * ev_future_when_all_n(ev_exec_t *exec, size_t n, ev_future_t *const *futures)
Creates a future that becomes ready when all of the input futures become ready or one of the input fu...
Definition future.c:441
void * ev_future_get(const ev_future_t *future)
Returns the result of a ready future.
Definition future.c:356
void ev_future_submit(ev_future_t *future, struct ev_task *task)
Submits a task to be executed once the specified future is ready.
Definition future.c:364
void ev_future_release(ev_future_t *future)
Releases a reference to a future.
Definition future.c:328
ev_future_t * ev_future_acquire(ev_future_t *future)
Acquires a reference to a future.
Definition future.c:320
ev_future_t * ev_future_when_any_v(ev_exec_t *exec, ev_future_t *future, va_list ap)
Equivalent to ev_future_when_any(), except that it accepts a va_list instead of a variable number of ...
Definition future.c:486
ev_promise_t * ev_promise_create(size_t size, ev_promise_dtor_t *dtor)
Constructs a new promise with an optional empty shared state.
Definition future.c:154
int ev_future_is_ready(const ev_future_t *future)
Checks if the specified future is ready, i.e., its associated promise has been satisfied.
Definition future.c:341
int ev_promise_set_acquire(ev_promise_t *promise)
Checks if the specified promise can be satisfied by the caller and, if so, prevents others from satis...
Definition future.c:251
This is the public header file of the event library.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition ev.h:29
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
A future.
Definition future.c:66
void * value
The value of the future, set by ev_promise_set_release().
Definition future.c:79
A promise.
Definition future.c:95
An executable task.
Definition task.h:41