µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
|
Defines signals and relays, structures used to communicate asynchronously between distant parts of the application. More...
#include "uevloop/utils/linked-list.h"
#include "uevloop/utils/closure.h"
#include "uevloop/utils/promise.h"
#include "uevloop/system/containers/system-pools.h"
#include "uevloop/system/containers/system-queues.h"
#include "uevloop/system/event.h"
Go to the source code of this file.
Data Structures | |
struct | uel_signal_relay_t |
Contains a signal vector and operates on in. More... | |
Typedefs | |
typedef uintptr_t | uel_signal_t |
typedef struct uel_event_listener * | uel_signal_listener_t |
Defines a reference type suitable to manipulate the actual listener event's context. | |
Functions | |
void | uel_signal_relay_init (uel_signal_relay_t *relay, uel_syspools_t *pools, uel_sysqueues_t *queues, uel_llist_t *buffer, uintptr_t width) |
Initialises a signal relay. More... | |
uel_signal_listener_t | uel_signal_listen (uel_signal_t signal, uel_signal_relay_t *relay, uel_closure_t *closure) |
Attaches a listener closure to some signal at a particular relay. More... | |
uel_signal_listener_t | uel_signal_listen_once (uel_signal_t signal, uel_signal_relay_t *relay, uel_closure_t *closure) |
Attaches a listener closure to some signal at a particular relay. The listener closure will be invoked only once. More... | |
void | uel_signal_unlisten (uel_signal_listener_t listener) |
Marks a signal listener as expired. When its corresponding signal is emitted, this listener's closure will not be invoked and the listener will be destroyed. More... | |
void | uel_signal_emit (uel_signal_t signal, uel_signal_relay_t *relay, void *params) |
Emits a signal at the supplied relay. Any closure listening to this signal will be asynchronously invoked. More... | |
uel_signal_listener_t | uel_signal_resolve_promise (uel_signal_t signal, uel_signal_relay_t *relay, uel_promise_t *promise) |
Attaches a non-repeating listener that resolves the provided promise upon emission. More... | |
uel_signal_listener_t | uel_signal_reject_promise (uel_signal_t signal, uel_signal_relay_t *relay, uel_promise_t *promise) |
Attaches a non-repeating listener that rejects the provided promise upon emission. More... | |
Defines signals and relays, structures used to communicate asynchronously between distant parts of the application.
Any signal is defined as an unsigned integer type. This means that any signal type is only valid within the scope defined by the relay designed to respond to said signal.
void uel_signal_emit | ( | uel_signal_t | signal, |
uel_signal_relay_t * | relay, | ||
void * | params | ||
) |
Emits a signal at the supplied relay. Any closure listening to this signal will be asynchronously invoked.
signal | The signal to be emitted |
relay | The relay where the signal is registered |
params | The parameters supplied to the listener's closure when it is invoked. |
uel_signal_listener_t uel_signal_listen | ( | uel_signal_t | signal, |
uel_signal_relay_t * | relay, | ||
uel_closure_t * | closure | ||
) |
Attaches a listener closure to some signal at a particular relay.
signal | The signal to be listened for |
relay | The relay where the listener will be registered |
closure | The closure to be invoked when the signal is emitted. The closure will be invoked with whatever parameters are supplied during emission. |
uel_signal_listener_t uel_signal_listen_once | ( | uel_signal_t | signal, |
uel_signal_relay_t * | relay, | ||
uel_closure_t * | closure | ||
) |
Attaches a listener closure to some signal at a particular relay. The listener closure will be invoked only once.
signal | The signal to be listened for |
relay | The relay where the listener will be registered |
closure | The closure to be invoked when the signal is emitted. The closure will be invoked with whatever parameters are supplied during emission. |
uel_signal_listener_t uel_signal_reject_promise | ( | uel_signal_t | signal, |
uel_signal_relay_t * | relay, | ||
uel_promise_t * | promise | ||
) |
Attaches a non-repeating listener that rejects the provided promise upon emission.
signal | The signal to be listened for |
relay | The relay where the signal is registered |
promise | The promise to be rejected upon signal emission |
void uel_signal_relay_init | ( | uel_signal_relay_t * | relay, |
uel_syspools_t * | pools, | ||
uel_sysqueues_t * | queues, | ||
uel_llist_t * | buffer, | ||
uintptr_t | width | ||
) |
Initialises a signal relay.
relay | The signal relay object to be initialised |
pools | The system's internal pools |
queues | The system's internal queues |
buffer | The buffer that will be used to store listeners registered at this relay. Must be the number of signals bound to this relay wide. |
width | The number of signals bound to this relay. |
uel_signal_listener_t uel_signal_resolve_promise | ( | uel_signal_t | signal, |
uel_signal_relay_t * | relay, | ||
uel_promise_t * | promise | ||
) |
Attaches a non-repeating listener that resolves the provided promise upon emission.
signal | The signal to be listened for |
relay | The relay where the signal is registered |
promise | The promise to be resolved upon signal emission |
void uel_signal_unlisten | ( | uel_signal_listener_t | listener | ) |
Marks a signal listener as expired. When its corresponding signal is emitted, this listener's closure will not be invoked and the listener will be destroyed.
listener | The listener that identifies the listen operation to be undone |