-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.h
39 lines (34 loc) · 993 Bytes
/
worker.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
#ifndef WORKER_H
#define WORKER_H
#include <mutex>
#include <queue>
#include<unordered_map>
#include "allForLibevent.h"
class Request;
//class Task;
typedef size_t clientId_t;
class Worker
{
public:
Worker();
~Worker();
void sleep();
void run();
void wakeup();
void addTask(Task* task);
void deleteTask(Task* task);
void useParsedRequestFactory(ParsedRequestFactory* parsedRequestFactory);
void useMatcher(Matcher* matcher);
std::shared_ptr<Request> getRequest(Outputable* output);
void deleteRequest(clientId_t clientId);
std::shared_ptr<ParsedRequestFactory> getParsedRequestFactory();
std::shared_ptr<Matcher> getMatcher();
int getRequestNum();
private:
std::shared_ptr<Matcher> matcher;
std::mutex taskQuequeBlock;
ThreadsafeQueue<Task*> taskQueque;
std::unordered_map<clientId_t, std::shared_ptr<Request>> clientIdToRequest;
std::shared_ptr<ParsedRequestFactory> parsedRequestFactory;
};
#endif // WORKER_H