forked from zhanghao731/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLThread.cpp
38 lines (27 loc) · 821 Bytes
/
CLThread.cpp
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
#include "CLThread.h"
CLThread::CLThread(CLExecutiveFunctionProvider* pExecutiveFunctionProvider):CLExecutive(pExecutiveFunctionProvider) {
}
CLThread::~CLThread() {
}
void* CLThread::StartFunctionOfThread(void *pThis){
CLThread* pThreadThis=(CLThread *)pThis;
std::cout<<std::endl<<"线程ID:"<<pThreadThis->m_ThreadID<<std::endl;
pThreadThis->m_pExecutiveFunctionProvider->RunExecutiveFunction();
return 0;
}
void CLThread::Run(){
int r=pthread_create(&m_ThreadID,0,StartFunctionOfThread,this);
if(r!=0)
{
std::cout<<"pthread_create error"<<std::endl;
return ;
}
}
void CLThread::WaitForDeath(){
int r=pthread_join(m_ThreadID,0);
if(r!=0)
{
std::cout<<"In CLThread::WaitForDeath(),pthread_join error"<<std::endl;
return ;
}
}