Source code for elos/eventdispatcher/types.h

// SPDX-License-Identifier: MIT
#pragma once

#include <pthread.h>
#include <safu/flags.h>
#include <time.h>

#include "elos/eventbuffer/types.h"
#include "elos/eventprocessor/types.h"

[docs][docs]/******************************************************************* * Parameter for EventDispatcher initialization * * Members: * eventProcessor: The EventProcessor the Events shall be dispatched to * pollTimeout: Timeout for the poll() command that is waiting for eventfd writes * Can be NULL, in this case ELOS_EVENTDISPATCHER_DEFAULT_POLL_TIMEOUT is used. * healthTimeInterval: Minimum time interval for health events to be published (can be more). * Can be NULL, in this case ELOS_EVENTDISPATCHER_DEFAULT_HEALTH_INTERVAL is used. ******************************************************************/ typedef struct elosEventDispatcherParam {
[docs][docs] elosEventProcessor_t *eventProcessor;
[docs][docs] struct timespec const *pollTimeout;
[docs][docs] struct timespec const *healthTimeInterval;
} elosEventDispatcherParam_t;
[docs][docs]/******************************************************************* * Data structure of an EventDispatcher's worker thread * * Members: * thread: Posix thread identifiert * trigger: Eventfd used for synchronization between worker thread and the EventDispatcher * pollTimeout: Timeout for the poll() command that is waiting for eventfd writes * healthTimeInterval: Minimum time interval for health events to be published (can be more) * healthTimeTreshold: Timestamp used for testing if a health event needs to be published * eventsPublished: Published events since the last health event ******************************************************************/ typedef struct elosEventDispatcherWorker {
[docs][docs] pthread_t thread;
[docs][docs] int trigger;
[docs][docs] struct timespec pollTimeout;
[docs][docs] struct timespec healthTimeInterval;
[docs][docs] struct timespec healthTimeTreshold;
[docs][docs] size_t eventsPublished;
} elosEventDispatcherWorker_t;
[docs][docs]/******************************************************************* * Data structure of an EventDispatcher * * Members: * flags: contains the component status bits, e.g. initialized, active * lock: mutex for ensuring thread safe access to the EventDispatcher * sync: eventfd used for synchronization between EventDispatcher and its worker thread * worker: data structure for the EventDispatcher worker thread * eventBufferPtrVector: contains the EventBuffers the EventDispatcher is monitoring * eventProcessor: the EventProcessor the Events shall be dispatched to ******************************************************************/ typedef struct elosEventDispatcher {
[docs][docs] safuFlags_t flags;
[docs][docs] pthread_mutex_t lock;
[docs][docs] int sync;
[docs][docs] elosEventDispatcherWorker_t worker;
[docs][docs] elosEventBufferPtrVector_t eventBufferPtrVector;
[docs][docs] elosEventProcessor_t *eventProcessor;
} elosEventDispatcher_t;