µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
|
Go to the documentation of this file.
47 uel_promise_segment_t *
next;
104 uel_objpool_t *promise_pool,
105 uel_objpool_t *segment_pool
157 uel_promise_t *promise,
158 uel_closure_t resolve,
197 uel_promise_t *promise,
226 #ifdef UEL_PROMISE_SHORTCUTS
228 #define THEN uel_promise_then
229 #define CATCH uel_promise_catch
230 #define AFTER uel_promise_after
231 #define ALWAYS uel_promise_always
An issuer of promises. Contains references to pools for promises and segments.
Definition: promise.h:90
void uel_promise_resettle(uel_promise_t *promise, uel_promise_state_t state, void *value)
Resettles a promise as the supplied state. Unlike uel_promise_resolve() and uel_promise_reject(),...
uel_objpool_t * promise_pool
A reference to the promise pool.
Definition: promise.h:92
uel_promise_t * uel_promise_create(uel_promise_store_t *store, uel_closure_t closure)
Acquires a new promise from the supplied store and binds it to the asynchronous operation started by ...
@ UEL_PROMISE_RESOLVED
A promise that has been resolved with some value.
Definition: promise.h:21
void * value
The value this promise holds. Only meaningful if already settled.
Definition: promise.h:79
uel_objpool_t * segment_pool
A reference to the segment pool.
Definition: promise.h:94
Defines closures, objects that bind functions to creating and calling contexts.
uel_promise_segment_t * last_segment
The last segment to be processed when this promise settles.
Definition: promise.h:83
void uel_promise_after(uel_promise_t *promise, uel_closure_t resolve, uel_closure_t reject)
Adds a new synchronous segment to the promise. Either of its closures will be invoked,...
uel_closure_t uel_promise_destroyer(uel_promise_t *promise)
Creates a closure bound to a promise. When the closure is invoked, the promise is destroyed....
uel_promise_state_t state
The current state of this promise.
Definition: promise.h:77
uel_promise_segment_t * next
The next synchronous segment to be processed.
Definition: promise.h:47
void uel_promise_then(uel_promise_t *promise, uel_closure_t resolve)
Adds a new synchronous segment to the promise. It will be invoked upon promise resolution....
@ UEL_PROMISE_REJECTED
A promise that has been rejected with some error.
Definition: promise.h:22
Defines object pools, arrays of pre-allocated objects for dynamic use.
uel_promise_segment_t * first_segment
The first segment to be processed when this promise settles.
Definition: promise.h:81
void uel_promise_always(uel_promise_t *promise, uel_closure_t always)
Adds a new synchronous segment to the promise. The same closure will be invoked on promise settling r...
struct uel_promise_store * source
The promise store from where this promise was issued.
Definition: promise.h:75
@ UEL_PROMISE_PENDING
A promise that has not been resolved nor rejected.
Definition: promise.h:20
uel_closure_t resolve
The closure to be invoked when the promise is resolved.
Definition: promise.h:43
uel_promise_store_t uel_promise_store_create(uel_objpool_t *promise_pool, uel_objpool_t *segment_pool)
Creates a new promise store from the promise and segment pools.
enum uel_promise_state uel_promise_state_t
Alias to the uel_promise_state enum.
Definition: promise.h:25
void uel_promise_reject(uel_promise_t *promise, void *value)
Settles a promise as rejected and, synchronously, invokes the reject closures of each segment in the ...
uel_promise_state
Defines the possible states for a prommise.
Definition: promise.h:19
uel_closure_t uel_promise_rejecter(uel_promise_t *promise)
Creates a closure bound to a promise. When the closure is invoked with some parameter,...
A promise is association of an asynchronous operation to the possible execution paths that follow its...
Definition: promise.h:73
uel_closure_t reject
The closure to be invoked when the promise is rejected.
Definition: promise.h:45
uel_closure_t uel_promise_resolver(uel_promise_t *promise)
Creates a closure bound to a promise. When the closure is invoked with some parameter,...
Defines a single synchronous operation to be invoked when the promise is either resolved or rejected.
Definition: promise.h:41
void uel_promise_destroy(uel_promise_t *promise)
Destroys a promise and all of its segments. Settling this promise afterwards yields undefined behavio...
void uel_promise_catch(uel_promise_t *promise, uel_closure_t reject)
Adds a new synchronous segment to the promise. It will be invoked upon promise rejection....
Central repository of system configuration. This is meant to be edited by the programmer as needed.
void uel_promise_resolve(uel_promise_t *promise, void *value)
Settles a promise as resolved and, synchronously, invokes the resolve closures of each segment in the...