-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNodeThread.h
50 lines (36 loc) · 976 Bytes
/
NodeThread.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
#ifndef NODETHREAD_H__
#define NODETHREAD_H__
#include <zthread/Thread.h>
#include <map>
#include <string>
#include <exception>
#include <boost/shared_ptr.hpp>
#include "JobTicket.h"
#include "ServerMessage.h"
#include "TQueue.h"
#include "Log.h"
#include "Server.h"
namespace FCPLib {
class Node;
typedef TQueue< JobTicket::Ptr > JobTicketQueue;
typedef ZThread::CountedPtr< JobTicketQueue > JobTicketQueuePtr;
class NodeThread : public ZThread::Runnable {
friend class Node;
Node* node;
JobTicketQueuePtr clientReqQueue;
std::string host_;
int port_;
boost::shared_ptr<Server> s;
std::map<std::string, JobTicket::Ptr > jobs[2]; // 0 -- local jobs, 1 -- global jobs
NodeThread(Node* n, std::string &host, int port, JobTicketQueuePtr clientReqQueue_) throw();
void sendClientReq(JobTicket::Ptr job);
void doMessage(ServerMessage::Ptr message);
public:
void run();
~NodeThread() {
jobs[0].clear();
jobs[1].clear();
}
};
}
#endif