Lely core libraries  2.2.5
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 
40 typedef struct ev_promise ev_promise_t;
41 
43 typedef struct ev_future ev_future_t;
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
55 typedef void ev_promise_dtor_t(void *ptr);
56 
71 
81 
91 void ev_promise_release(ev_promise_t *promise);
92 
99 int ev_promise_is_unique(const ev_promise_t *promise);
100 
102 void *ev_promise_data(const ev_promise_t *promise);
103 
119 int ev_promise_set(ev_promise_t *promise, void *value);
120 
129 
138 void ev_promise_set_release(ev_promise_t *promise, void *value);
139 
142 
152 
161 void ev_future_release(ev_future_t *future);
162 
169 int ev_future_is_unique(const ev_future_t *future);
170 
179 int ev_future_is_ready(const ev_future_t *future);
180 
191 void *ev_future_get(const ev_future_t *future);
192 
200 void ev_future_submit(ev_future_t *future, struct ev_task *task);
201 
212 size_t ev_future_cancel(ev_future_t *future, struct ev_task *task);
213 
223 size_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_
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:332
void ev_promise_release(ev_promise_t *promise)
Releases a reference to a promise.
Definition: future.c:195
ev_future_t * ev_future_when_any(ev_exec_t *exec, ev_future_t *future,...)
Equivalent to ev_future_when_any_n(), except that it accepts a variable number of arguments instead o...
Definition: future.c:468
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:218
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:478
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:492
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:399
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:386
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:239
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:272
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:309
ev_promise_t * ev_promise_acquire(ev_promise_t *promise)
Acquires a reference to a promise.
Definition: future.c:178
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:151
ev_future_t * ev_future_when_all(ev_exec_t *exec, ev_future_t *future,...)
Equivalent to ev_future_when_all_n(), except that it accepts a variable number of arguments instead o...
Definition: future.c:412
void * ev_future_get(const ev_future_t *future)
Returns the result of a ready future.
Definition: future.c:351
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:422
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:360
void * ev_promise_data(const ev_promise_t *promise)
Returns a pointer to the shared state of a promise.
Definition: future.c:233
ev_future_t * ev_future_acquire(ev_future_t *future)
Acquires a reference to a future.
Definition: future.c:317
void ev_future_release(ev_future_t *future)
Releases a reference to a future.
Definition: future.c:325
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:436
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:338
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:248
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:63
void * value
The value of the future, set by ev_promise_set_release().
Definition: future.c:76
A promise.
Definition: future.c:92
An executable task.
Definition: task.h:41