CLAM-Development  1.4.0
PooledThread.cxx
Go to the documentation of this file.
1 #include "PooledThread.hxx"
2 #include <pthread.h>
3 
4 namespace CLAM
5 {
6 typedef void *(*pthread_start_pfunc) (void *);
7 
8 PooledThread::PooledThread(ThreadPool* argThreadPoolPtr, bool argRealtime)
9 : Thread(argRealtime), mThreadPoolPtr(argThreadPoolPtr)
10 {
11 }
12 
14 {
15 }
16 
18 {
19  //CLAM_ASSERT( mHasCode, "The thread has no code to execute!" );
20 
21  mRunning = true;
22  pthread_create(&mThreadID,
23  NULL,
24  (pthread_start_pfunc) LaunchPooledThread,
25  this );
26 }
27 
28 
30 {
31  mThreadPoolPtr->ReturnThreadToPool(this);
32 }
33 
34 void* PooledThread::LaunchPooledThread( void* pvoid )
35 {
36  PooledThread* pSelf = (PooledThread*)pvoid;
37 
38  pSelf->mRunning=true;
39  pSelf->SetupPriorityPolicy();
40  pSelf->mThreadCode();
41  pSelf->mRunning = false;
42 
43  return NULL;
44 }
45 
46 
47 } // end namespace CLAM