-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathichunkmanager.cpp
More file actions
36 lines (32 loc) · 810 Bytes
/
ichunkmanager.cpp
File metadata and controls
36 lines (32 loc) · 810 Bytes
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
#include "ichunkmanager.h"
#include "ichunkworker.h"
#include "common.h"
#include "netio/networker.h"
bool ChunkManager::Initialize()
{
return true;
}
bool ChunkManager::Start()
{
for (int i = 1; i < (int)worker_.size(); i++)
{
pthread_t thread;
int rs = pthread_create(&thread, NULL, NetWorker::Start, worker_[i]);
if ( rs )
{
FATAL("pthread_create failed, errno is %d", rs);
return false;
}
}
worker_[0]->StartMain();
return true;
}
bool ChunkManager::AddSubpiece(uint8_t* data, uint32_t len)
{
vector<NetWorker*>::iterator iter = worker_.begin();
for(; worker_.end() != iter; ++iter)
{
dynamic_cast<ChunkWorker*>(*iter)->AddSubpieceData(data, len);
}
}
ChunkManager* g_chunkmanager = NULL;