forked from uroni/urbackup_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceWorker.h
50 lines (35 loc) · 992 Bytes
/
ServiceWorker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <vector>
#include <utility>
#include "Interface/Thread.h"
#include "Interface/Mutex.h"
#include "Interface/Condition.h"
#include "Interface/Pipe.h"
#include "socket_header.h"
#include "Interface/CustomClient.h"
const int MAX_CLIENTS=20;
class IService;
class CStreamPipe;
class CServiceWorker : public IThread
{
public:
CServiceWorker(IService *pService, std::string pName, IPipe * pExit, int pMaxClientsPerThread);
~CServiceWorker();
void operator ()(void);
int getAvailableSlots(void);
void AddClient(SOCKET pSocket, const std::string& endpoint);
void stop(void);
private:
void addNewClients(void);
std::vector<std::pair<ICustomClient*, CStreamPipe*> > clients;
std::vector<std::pair<SOCKET, std::string> > new_clients;
IMutex* mutex;
IMutex* nc_mutex;
ICondition* cond;
IPipe *exit;
int nClients;
int max_clients;
THREAD_ID tid;
std::string name;
IService *service;
volatile bool do_stop;
};