trafilo 0.1.0
Streaming event-handler framework in C
Loading...
Searching...
No Matches
dispatcher.h
Go to the documentation of this file.
1#ifndef DISPATCHER_H
2#define DISPATCHER_H
3#include "bounded_queue.h"
4#include "hashmap.h"
5
9typedef struct dispatcher_t {
10 bounded_queue_t *bounded_q; /* Working bounded queue*/
11 hashmap_t *hash_m; /* Events map*/
12
14
15 // Thread pools
16 size_t num_workers; /* Number of wokrer threads, fetched from trafilo_conifg_t*/
17 pthread_t *threads; /* Array of worker thread pool*/
18
19 // Lifecycle
20 volatile int done; /* Shutdown signaling*/
21 int started;
23
32 hashmap_t *hashmap,
33 const trafilo_config_t *trafilo_config);
34
40int dispatcher_start(dispatcher_t *dispatcher);
41
48void dispatcher_stop(dispatcher_t *dispatcher);
49
54void dispatcher_destroy(dispatcher_t *dispatcher);
55#endif
void dispatcher_stop(dispatcher_t *dispatcher)
Stop a running dispatcher. Wakes all listeners and producers, shutdowns working queue,...
Definition dispatcher.c:159
dispatcher_t * dispatcher_create(bounded_queue_t *bounded_q, hashmap_t *hashmap, const trafilo_config_t *trafilo_config)
Create a dispatcher instance.
Definition dispatcher.c:96
int dispatcher_start(dispatcher_t *dispatcher)
Start a dispatcher thread pool.
Definition dispatcher.c:139
void dispatcher_destroy(dispatcher_t *dispatcher)
Free the dispatcher and free memory.
Definition dispatcher.c:173
A Circular ring queue, fixed size, to create a pool of events to be parsed.
Definition bounded_queue.h:12
A Dispatcher type with user set configs.
Definition dispatcher.h:9
int started
Definition dispatcher.h:21
hashmap_t * hash_m
Definition dispatcher.h:11
size_t num_workers
Definition dispatcher.h:16
const trafilo_config_t * config
Definition dispatcher.h:13
volatile int done
Definition dispatcher.h:20
pthread_t * threads
Definition dispatcher.h:17
bounded_queue_t * bounded_q
Definition dispatcher.h:10
The hashmap structure.
Definition hashmap.h:26
Configuration struct for Trafilo framework.
Definition trafilo.h:81