trafilo 0.1.0
Streaming event-handler framework in C
Loading...
Searching...
No Matches
dispatcher.h File Reference
#include "bounded_queue.h"
#include "hashmap.h"

Go to the source code of this file.

Data Structures

struct  dispatcher_t
 A Dispatcher type with user set configs. More...

Functions

dispatcher_tdispatcher_create (bounded_queue_t *bounded_q, hashmap_t *hashmap, const trafilo_config_t *trafilo_config)
 Create a dispatcher instance.
int dispatcher_start (dispatcher_t *dispatcher)
 Start a dispatcher thread pool.
void dispatcher_stop (dispatcher_t *dispatcher)
 Stop a running dispatcher. Wakes all listeners and producers, shutdowns working queue, and drains fields, merge all dispatcher threads. Sets started flag to 0.
void dispatcher_destroy (dispatcher_t *dispatcher)
 Free the dispatcher and free memory.

Function Documentation

◆ dispatcher_create()

dispatcher_t * dispatcher_create ( bounded_queue_t * bounded_q,
hashmap_t * hashmap,
const trafilo_config_t * trafilo_config )

Create a dispatcher instance.

Parameters
bounded_qThe working queue.
hashmapThe event map.
trafilo_configThe user set config, includes the user set callback functions and the desired number of workers.
Returns
Pointer to dispatcher_t, NULL on creation failure.

◆ dispatcher_destroy()

void dispatcher_destroy ( dispatcher_t * dispatcher)

Free the dispatcher and free memory.

Parameters
dispatcherThe dispatcher to be destroyed.

◆ dispatcher_start()

int dispatcher_start ( dispatcher_t * dispatcher)

Start a dispatcher thread pool.

Parameters
dispatcherThe dispatcher to be started.
Returns
0 on success, -1 on empty dispatcher, -2 if already started.

◆ dispatcher_stop()

void dispatcher_stop ( dispatcher_t * dispatcher)

Stop a running dispatcher. Wakes all listeners and producers, shutdowns working queue, and drains fields, merge all dispatcher threads. Sets started flag to 0.

Parameters
dispatcherThe dispatcher to be stopped.