Provides utility functions for event handler threads. More...
Provides utility functions for event handler threads.
By using the module event_thread
, the event queues EVENT_PRIO_HIGHEST, EVENT_PRIO_MEDIUM, and EVENT_PRIO_LOWEST are provided and declared in the header event/thread.h
. With default settings, the auto_init
module will automatically start one or more threads to handle these queues.
By default, a single thread with priority EVENT_THREAD_MEDIUM_PRIO
will handle all three event queues according to their priority. An already started event handler will not be preempted in this case by an incoming higher priority event. Still, lower priority event queues will only be worked on once the higher priority queues are empty. Hence, the worst case latency is increased by the worst case duration of any possible lower priority event in this configuration.
By using module event_thread_highest
, the highest priority queue gets its own thread. With this, events of the highest priority can preempt already running event handlers of medium and lowest priority.
By using module event_thread_medium
, the lowest priority events are handled in their own thread. With this, events of at least medium priority can preempt already running events of the lowest priority.
By using both module event_thread_highest
and event_thread_medium
, each event queue gets its own thread. So higher priority events will always preempt events of lower priority in this case.
Event Thread API
Definition in file thread.h.
#include <stddef.h>
#include "event.h"
Go to the source code of this file.
#define | EVENT_PRIO_HIGHEST (&event_thread_queues[EVENT_QUEUE_PRIO_HIGHEST]) |
Pointer to the event queue handling highest priority events. | |
#define | EVENT_PRIO_MEDIUM (&event_thread_queues[EVENT_QUEUE_PRIO_MEDIUM]) |
Pointer to the event queue handling medium priority events. | |
#define | EVENT_PRIO_LOWEST (&event_thread_queues[EVENT_QUEUE_PRIO_LOWEST]) |
Pointer to the event queue handling lowest priority events. | |
enum | { EVENT_QUEUE_PRIO_HIGHEST , EVENT_QUEUE_PRIO_MEDIUM , EVENT_QUEUE_PRIO_LOWEST , EVENT_QUEUE_PRIO_NUMOF } |
Event queue priorities. More... | |
event_queue_t | event_thread_queues [EVENT_QUEUE_PRIO_NUMOF] |
void | event_thread_init_multi (event_queue_t *queues, size_t queues_numof, char *stack, size_t stack_size, unsigned priority) |
Convenience function for initializing an event queue thread handling multiple queues. | |
static void | event_thread_init (event_queue_t *queue, char *stack, size_t stack_size, unsigned priority) |
Convenience function for initializing an event queue thread. | |
#define EVENT_PRIO_HIGHEST (&event_thread_queues[EVENT_QUEUE_PRIO_HIGHEST]) |
#define EVENT_PRIO_LOWEST (&event_thread_queues[EVENT_QUEUE_PRIO_LOWEST]) |
#define EVENT_PRIO_MEDIUM (&event_thread_queues[EVENT_QUEUE_PRIO_MEDIUM]) |
anonymous enum |
Event queue priorities.
The lower the numeric value, the higher the priority. The highest priority is 0, so that these priorities can be used as index to access arrays.
|
inlinestatic |
void event_thread_init_multi | ( | event_queue_t * | queues, |
size_t | queues_numof, | ||
char * | stack, | ||
size_t | stack_size, | ||
unsigned | priority | ||
) |
Convenience function for initializing an event queue thread handling multiple queues.
[in] | queues | array of the preallocated queue objects |
[in] | queues_numof | number of elements in queues |
[in] | stack | ptr to stack space |
[in] | stack_size | size of stack |
[in] | priority | priority to use |
queues_numof
is at most 4