NymphRPC Remote Procedure Call Library
dispatcher.h
1 /*
2  dispatcher.h - header file for the Dispatcher class.
3 
4  Revision 0
5 
6  Notes:
7  -
8 
9  2016/11/19, Maya Posch
10  (c) Nyanko.ws.
11 */
12 
13 
14 #pragma once
15 #ifndef DISPATCHER_H
16 #define DISPATCHER_H
17 
18 #include "abstract_request.h"
19 #include "worker.h"
20 
21 #include <queue>
22 #include <mutex>
23 #include <thread>
24 #include <vector>
25 
26 
27 class Dispatcher {
28  static std::queue<AbstractRequest*> requests;
29  static std::queue<Worker*> workers;
30  static std::mutex requestsMutex;
31  static std::mutex workersMutex;
32  static std::vector<Worker*> allWorkers;
33  static std::vector<std::thread*> threads;
34 
35 public:
36  static bool init(int workers);
37  static bool stop();
38  static void addRequest(AbstractRequest* request);
39  static bool addWorker(Worker* worker);
40 };
41 
42 #endif
Definition: abstract_request.h:22
Definition: dispatcher.h:27
Definition: worker.h:24