µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
Data Structures | Typedefs | Enumerations | Functions
event.h File Reference

Defines events and methods to configure events. More...

#include "uevloop/utils/closure.h"
#include "uevloop/utils/linked-list.h"
Include dependency graph for event.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uel_event_t
 Events are special messages passed around the core. They represent tasks to be run at some point by the system. More...
 
union  uel_event_t::uel_event_detail
 
struct  uel_event_t::uel_event_detail::uel_event_timer
 Contains information suitable for scheduling an event at the scheduler. More...
 
struct  uel_event_t::uel_event_detail::uel_event_signal
 Contains information related to an emitted signal. More...
 
struct  uel_event_t::uel_event_detail::uel_event_listener
 Contains the context of a particular signal listener. More...
 
struct  uel_event_t::uel_event_detail::uel_event_observer
 Contains the reference to an observer variable. More...
 

Typedefs

typedef enum uel_event_type uel_event_type_t
 Alias to the uel_event_type enum.
 
typedef enum uel_event_timer_status uel_event_timer_status_t
 Alias to the uel_event_timer_status.
 

Enumerations

enum  uel_event_type {
  UEL_CLOSURE_EVENT, UEL_TIMER_EVENT, UEL_SIGNAL_EVENT, UEL_SIGNAL_LISTENER_EVENT,
  UEL_OBSERVER_EVENT
}
 Possible types of events understood by the core.
 
enum  uel_event_timer_status { UEL_TIMER_RUNNING, UEL_TIMER_PAUSED, UEL_TIMER_CANCELLED }
 Possible statuses for a timer event.
 

Functions

void uel_event_config_closure (uel_event_t *event, uel_closure_t *closure, void *value, bool repeating)
 Configures a closure event. More...
 
void uel_event_config_signal (uel_event_t *event, uintptr_t signal, uel_llist_t *listeners, void *params)
 Configures a signal event. More...
 
void uel_event_config_signal_listener (uel_event_t *event, uel_closure_t *closure, bool repeating)
 Configures a signal listener event. More...
 
void uel_event_config_observer (uel_event_t *event, uel_closure_t *closure, volatile uintptr_t *condition_var, bool repeating)
 Configures an observer event. More...
 
void uel_event_observer_cancel (uel_event_t *event)
 Cancels an observer. More...
 
void uel_event_config_timer (uel_event_t *event, uint16_t timeout_in_ms, bool repeating, bool immediate, uel_closure_t *closure, void *value, uint32_t current_time)
 Configures a timer event. More...
 
void uel_event_timer_pause (uel_event_t *event)
 Pauses a timer event. More...
 
void uel_event_timer_resume (uel_event_t *event)
 Resumes a paused timer event. More...
 
void uel_event_timer_cancel (uel_event_t *event)
 Cancels a timer event. More...
 

Detailed Description

Defines events and methods to configure events.

Function Documentation

◆ uel_event_config_closure()

void uel_event_config_closure ( uel_event_t *  event,
uel_closure_t *  closure,
void *  value,
bool  repeating 
)

Configures a closure event.

Parameters
eventThe event to be configured
closureThe closure to be invoked when the event is run
valueThe value to supply to the closure as parameters when it is invoked
repeatingIntructs the system whether should this event be disposed of after processing

◆ uel_event_config_observer()

void uel_event_config_observer ( uel_event_t *  event,
uel_closure_t *  closure,
volatile uintptr_t *  condition_var,
bool  repeating 
)

Configures an observer event.

Parameters
eventThe event to be configured
closureThe closure to be invoked when the observed value changes
condition_varThe address of a volatile variable to be observed
repeatingIntructs the system whether should this event be disposed of after processing

◆ uel_event_config_signal()

void uel_event_config_signal ( uel_event_t *  event,
uintptr_t  signal,
uel_llist_t *  listeners,
void *  params 
)

Configures a signal event.

Parameters
eventThe event to be configured
signalThe integer value that identifies this signal
listenersThe listeners associated to this signal
paramsThe parameters associated with this signal emission

◆ uel_event_config_signal_listener()

void uel_event_config_signal_listener ( uel_event_t *  event,
uel_closure_t *  closure,
bool  repeating 
)

Configures a signal listener event.

Parameters
eventThe event to be configured
closureThe closure to be invoked when the event is run
repeatingIntructs the system whether should this event be disposed of after processing

◆ uel_event_config_timer()

void uel_event_config_timer ( uel_event_t *  event,
uint16_t  timeout_in_ms,
bool  repeating,
bool  immediate,
uel_closure_t *  closure,
void *  value,
uint32_t  current_time 
)

Configures a timer event.

Parameters
eventThe event to be configured
timeout_in_msThe delay to process this event. If the event is repeating, this defines the interval between successive executions.
repeatingIf this flag is set, the event will not be destroyed after execution. Instead it will be put on the schedule queue.
immediateIf this flag is set, a recurring timer will be immediately enqueued for processing. One-shot timers will ignore this setting.
closureThe closure to be invoked when the timer expires
valueThe value to supply to the closure as parameters when it is invoked
current_timeThe current value set in the system counter.

◆ uel_event_observer_cancel()

void uel_event_observer_cancel ( uel_event_t *  event)

Cancels an observer.

Parameters
eventThe observer event to be cancelled

◆ uel_event_timer_cancel()

void uel_event_timer_cancel ( uel_event_t *  event)

Cancels a timer event.

Parameters
eventThe timer event to be cancelled

◆ uel_event_timer_pause()

void uel_event_timer_pause ( uel_event_t *  event)

Pauses a timer event.

Parameters
eventThe timer event to be paused

◆ uel_event_timer_resume()

void uel_event_timer_resume ( uel_event_t *  event)

Resumes a paused timer event.

Parameters
eventThe timer event to be resumed