-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseThread.h
More file actions
39 lines (31 loc) · 795 Bytes
/
baseThread.h
File metadata and controls
39 lines (31 loc) · 795 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
37
38
39
#ifndef CPP_UTIL_THREAD_POOL_BASETHREAD_H
#define CPP_UTIL_THREAD_POOL_BASETHREAD_H
#include <pthread.h>
#include "common/common.h"
#include "nonCopyable.h"
USING_NAMESPACE(std)
NAMESPACE_SETUP(Util)
class BaseThread: public NonCopyable {
public:
BaseThread();
virtual ~BaseThread();
private:
BaseThread(const BaseThread&);
BaseThread& operator=(const BaseThread&);
private:
/*
* 1. thread start function must be a static
* */
static void* WorkFun(void* baseThread);
public:
virtual void Run()=0;
void Start();
void Join();
private:
pthread_t mThreadId;
bool mIsStart;
bool mIsJoin;
}; //class BaseThread
typedef std::tr1::shared_ptr<BaseThread> BaseThreadPtr;
NAMESPACE_END(Util)
#endif //CPP_UTIL_THREAD_POOL_BASETHREAD_H