|
utils
utilities in C for microcontrollers
|
an implementation of the publish/subscribe pattern More...
#include "list.h"Go to the source code of this file.
Data Structures | |
| struct | event |
| event state More... | |
| struct | event_handler |
| event handler state More... | |
Macros | |
| #define | EVENT_HANDLER_INIT(handler_fun) |
| allows static initialization of an event_handler More... | |
| #define | EVENT_INIT(event) { .handlers = LIST_INIT((event).handlers) } |
| allows static initialization of an event More... | |
Functions | |
| int | event_handler_init (struct event_handler *handler, void(*fun)(struct event *, void *)) |
| initialize an event handler More... | |
| int | event_init (struct event *evt) |
| initialize a event More... | |
| int | event_subscribe (struct event *evt, struct event_handler *handler) |
| attach an event_handler to an event More... | |
| int | event_unsubscribe (struct event *evt, struct event_handler *handler) |
| detach an event_handler from an event More... | |
| int | event_publish (struct event *evt, void *ctx) |
| publish an event More... | |
an implementation of the publish/subscribe pattern
depends on list.h
| #define EVENT_HANDLER_INIT | ( | handler_fun | ) |
allows static initialization of an event_handler
allows static initialization of an event
| int event_handler_init | ( | struct event_handler * | handler, |
| void(*)(struct event *, void *) | fun | ||
| ) |
initialize an event handler
| handler | pointer to event_handler |
| fun | a function to be called when the subscribed event is published |
| int event_init | ( | struct event * | evt | ) |
| int event_publish | ( | struct event * | evt, |
| void * | ctx | ||
| ) |
publish an event
all subscribed events will have their handler functions called in an unspecified order
| evt | pointer to initialized event |
| ctx | pointer to context to pass to subscribed event_handler functions |
| int event_subscribe | ( | struct event * | evt, |
| struct event_handler * | handler | ||
| ) |
attach an event_handler to an event
| evt | pointer to initialized event |
| handler | pointer to initialized event_handler |
| int event_unsubscribe | ( | struct event * | evt, |
| struct event_handler * | handler | ||
| ) |
detach an event_handler from an event
| evt | pointer to initialized event |
| handler | pointer to initialized event_handler |
1.8.14