TDME2  1.9.200
ServerWorkerThreadPool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
11 
12 using std::vector;
13 using std::unique_ptr;
14 
17 
18 namespace tdme {
19 namespace network {
20 namespace udpserver {
21 
22 class ServerRequest;
23 
24 /**
25  * @brief Simple server worker thread pool class
26  * @author Andreas Drewke
27  */
28 class ServerWorkerThreadPool final: public Queue<ServerRequest> {
29  friend class ServerWorkerThread;
30 
31 public:
32  // forbid class copy
34 
35  /**
36  * @brief Public constructor
37  * @param workerCount worker count
38  * @param maxElements max elements
39  * @param startUpBarrier start up barrier
40  */
41  ServerWorkerThreadPool(const unsigned int workerCount, const unsigned int maxElements, Barrier* startUpBarrier);
42 
43  /**
44  * @brief Public destructor
45  */
46  virtual ~ServerWorkerThreadPool();
47 
48  /**
49  * @brief Start worker thread pool
50  */
51  void start();
52 
53  /**
54  * @brief Stop worker thread pool
55  */
56  void stop();
57 private:
59  unsigned int workerCount;
60  vector<unique_ptr<ServerWorkerThread>> worker;
61 };
62 
63 };
64 };
65 };
Simple server worker thread pool class.
vector< unique_ptr< ServerWorkerThread > > worker
ServerWorkerThreadPool(const unsigned int workerCount, const unsigned int maxElements, Barrier *startUpBarrier)
Public constructor.
Barrier implementation.
Definition: Barrier.h:21
Consumer/producer queue.
Definition: Queue.h:26
Definition: fwd-tdme.h:4
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6