-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathichunkworker.h
75 lines (61 loc) · 1.81 KB
/
ichunkworker.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef CHUNKWORKER_H
#define CHUNKWORKER_H
#include "netio/networker.h"
#include "netio/netio.h"
#include "p2p/p2ptimersmanager.h"
#include "cutmachine.h"
#include <vector>
class ChunkProcess;
class ChunkWorker : public NetWorker
{
public:
ChunkWorker();
~ChunkWorker();
virtual BaseProcess* CreateProcess();
virtual void Start();
virtual void StartMain();
bool AddSubpieceData(uint8_t* data, uint32_t len);
bool GetSubpieceData(uint8_t* buffer, uint32_t len);
bool AddSrcInfo(int32_t fd, ChunkProcess* process);
bool EarseSrcInfo(int32_t fd);
bool AddTimer(P2PTimerEvent* timer);
void RemoveTimer(P2PTimerEvent* timer);
void UpdateTimer(P2PTimerEvent* timer);
protected:
struct SubPieceData
{
uint8_t bin_data[OUTBUFFER_LEN];
SubPieceData* next;
SubPieceData();
~SubPieceData(){};
void SetData(uint8_t* data, uint32_t len);
};
struct SrcimgInfo
{
int32_t fd;
ChunkProcess* process;
SrcimgInfo()
{
fd = -1; process = NULL;
};
/*
SrcimgInfo(const SrcimgInfo& item)
{
fd = item.fd;
process = item.process;
}
SrcimgInfo& operator =(const SrcimgInfo item)
{
fd = item.fd;
process = item.process;
}*/
};
typedef tr1::unordered_map<int32_t, ChunkProcess*> SrcimgProcessMap;
typedef SrcimgProcessMap::iterator SrcimgProcessIter;
SrcimgProcessMap src_process_map_;
//std::vector<SrcimgInfo*> client_list_; // srcimg client info
P2PList<SubPieceData>* subpiece_data_list_; //subpiece data that need to send to client which is in client list
P2PTimersManager *timers_manager_; //timer, check client that is timeout
private:
};
#endif