34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
/** \file dispatcher.h
|
|
* Contains the declarations for the dispatcher functionality. It is
|
|
* basically a separate thread that spins infinitely listening for
|
|
* connections on a specified port, and dispatching incoming
|
|
* connections to the specified worker threads.
|
|
*/
|
|
|
|
#ifndef _DISPATCHER_H_
|
|
#define _DISPATCHER_H_
|
|
|
|
#include "networking.h"
|
|
|
|
/* Worker function that the worker threads will be started with. */
|
|
typedef void*(*workerfunc)(void*);
|
|
|
|
/*
|
|
* Initializes the dispatcher. pnum is the port number on which we
|
|
* would like to start listening to connections. The worker_count
|
|
* parameter is the number of worker threads to spawn for handling
|
|
* requests. f is the run function for worker threads. Returns zero
|
|
* upon success and various numbers on failures.
|
|
*/
|
|
int dispatcher_initialize(port_t port, int worker_count, workerfunc f);
|
|
|
|
/* Starts up the dispatcher and worker threads. Returns zero on
|
|
* success, and error numbers on errors. */
|
|
int dispatcher_start();
|
|
|
|
/* Stops the dispatcher and worker threads and performs
|
|
* clean-up. Returns zero on success, and error numbers on errors. */
|
|
int dispatcher_stop();
|
|
|
|
#endif/*_DISPATCHER_H_*/
|