-
Notifications
You must be signed in to change notification settings - Fork 1
/
CpThread.h
45 lines (34 loc) · 1.1 KB
/
CpThread.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
/*
* CpThread.h
*
* Created on: 2014-10-23
* Author: hgw
*/
#ifndef CPTHREAD_H_
#define CPTHREAD_H_
#include "CpFileInfo.h"
#include <pthread.h>
#include <string>
class CpThread
{
public:
CpThread(CpFileInfo& fileInfo, hostinfo* host);
bool start();
int join();
inline dirpair* getCpFileInfo() {return fileInfo_.popDirPair();}
inline void putSuccCpFileInfo(int taskId, time_t start, time_t end, short retry) {fileInfo_.updateResult(taskId, true, start, end, host_->host_.c_str(), retry);}
inline void putFailCpFileInfo(int taskId, time_t start, time_t end, short retry) {fileInfo_.updateResult(taskId, false, start, end, host_->host_.c_str(), retry);}
inline void putProcessCpFileInfo(int taskId) {fileInfo_.updateProcess(taskId);}
std::string buildCommand(dirpair* p);
public:
static void strReplace(std::string& str, std::string strFind, std::string strReplace);
static void strConvert(std::string& str);
private:
CpFileInfo& fileInfo_;
hostinfo* host_;
pthread_t pthreadId_;
private:
CpThread( const CpThread& );
CpThread& operator=( const CpThread& );
};
#endif /* CPTHREAD_H_ */