µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
|
Defines closures, objects that bind functions to creating and calling contexts. More...
Go to the source code of this file.
Data Structures | |
struct | uel_closure_t |
Defines a closure, a tuple <function, context, destructor> More... | |
Typedefs | |
typedef void *(* | uel_closure_function_t) (void *context, void *params) |
Defines a closure function, suitable for being bound at a closure. More... | |
Functions | |
uel_closure_t | uel_closure_create (uel_closure_function_t function, void *context) |
Creates a new closure. More... | |
void * | uel_closure_invoke (uel_closure_t *closure, void *params) |
Invokes a closure and returns whatever value it returned. More... | |
uel_closure_t | uel_nop () |
Returns a closure that does nothing. More... | |
Defines closures, objects that bind functions to creating and calling contexts.
typedef void*(* uel_closure_function_t) (void *context, void *params) |
Defines a closure function, suitable for being bound at a closure.
Must take two pointers ar arguments, one for the context and one for closure parameters. Must return a void pointer.
uel_closure_t uel_closure_create | ( | uel_closure_function_t | function, |
void * | context | ||
) |
Creates a new closure.
Binds the tuple <function, context> and populates a new closure object with it. The object is returned by value.
function | The function to be run on closure invokation. |
context | The creation context of the closure. |
void* uel_closure_invoke | ( | uel_closure_t * | closure, |
void * | params | ||
) |
Invokes a closure and returns whatever value it returned.
closure | The closure reference to be invoked. |
params | The parameters to be passed along during closure invokation. |
uel_closure_t uel_nop | ( | ) |
Returns a closure that does nothing.
The returned closure can be passed as parameters to functions that take closures as callbacks when the caller does not need to callback.