PooledThread.cxx

Go to the documentation of this file.
00001 #include "PooledThread.hxx"
00002 #include <pthread.h>
00003 
00004 namespace CLAM
00005 {
00006 typedef void *(*pthread_start_pfunc) (void *);
00007 
00008 PooledThread::PooledThread(ThreadPool* argThreadPoolPtr, bool argRealtime)
00009 : Thread(argRealtime), mThreadPoolPtr(argThreadPoolPtr)
00010 {
00011 }
00012 
00013 PooledThread::~PooledThread()
00014 {
00015 }
00016 
00017 void PooledThread::Start()
00018 {
00019         //CLAM_ASSERT( mHasCode, "The thread has no code to execute!" );
00020 
00021         mRunning = true;
00022         pthread_create(&mThreadID,
00023                                         NULL,
00024                                         (pthread_start_pfunc) LaunchPooledThread,
00025                                         this );
00026 }
00027 
00028 
00029 void PooledThread::ReturnToPool()
00030 {
00031         mThreadPoolPtr->ReturnThreadToPool(this);
00032 }
00033 
00034 void* PooledThread::LaunchPooledThread( void* pvoid )
00035 {
00036         PooledThread* pSelf = (PooledThread*)pvoid;
00037 
00038         pSelf->mRunning=true;
00039         pSelf->SetupPriorityPolicy();
00040         pSelf->mThreadCode();
00041         pSelf->mRunning = false;
00042 
00043         return NULL;
00044 }
00045 
00046 
00047 } // end namespace CLAM
Generated by  doxygen 1.6.3