AioSignalHandlerThread Class Reference

Inheritance diagram for AioSignalHandlerThread:

Thread List of all members.

Public Member Functions

 AioSignalHandlerThread (AioSignalScheduler &schedulerInit)
virtual void run ()
virtual void start ()
 Spawns the OS thread.
void join ()
 Waits for the OS thread to terminate.
bool isStarted () const
 
Returns:
true if start has been called (and subsequent join has not completed)

bool isStopped () const
 
Returns:
opposite of isStarted()

boost::thread & getBoostThread ()
 Accesses the underlying boost::thread, e.g.
std::string getName ()
void setName (std::string const &s)

Protected Member Functions

void initAndRun ()
virtual void beforeRun ()
virtual void afterRun ()

Protected Attributes

boost::thread * pBoostThread
bool bRunning
std::string name

Private Attributes

AioSignalSchedulerscheduler

Detailed Description

Definition at line 38 of file AioSignalScheduler.cpp.


Constructor & Destructor Documentation

AioSignalHandlerThread::AioSignalHandlerThread ( AioSignalScheduler schedulerInit  )  [inline]

Definition at line 42 of file AioSignalScheduler.cpp.

00043         : scheduler(schedulerInit)
00044     {
00045     }


Member Function Documentation

void AioSignalHandlerThread::run (  )  [virtual]

Implements Thread.

Definition at line 156 of file AioSignalScheduler.cpp.

References AioSignalScheduler::quit, and scheduler.

00157 {
00158     int rc;
00159 
00160     // unblock signal in this thread only
00161     sigset_t mask;
00162     sigemptyset(&mask);
00163     sigaddset(&mask,SIGRTMIN);
00164     rc = pthread_sigmask(SIG_UNBLOCK,&mask,NULL);
00165     assert(!rc);
00166 
00167     // NOTE: had to boost priority of this thread to get signal handler
00168     // to run frequently.
00169 #ifdef sun
00170     int policy;
00171     sched_param param;
00172     rc = pthread_getschedparam(pthread_self(),&policy,&param);
00173     assert(!rc);
00174     param.sched_priority++;
00175     rc = pthread_setschedparam(pthread_self(),SCHED_RR,&param);
00176     assert(!rc);
00177 #endif
00178 
00179     // NOTE: using a condition variable causes the signal handler
00180     // to run too infrequently.  Try again after switching threading models.
00181     while (!scheduler.quit) {
00182         sleep(1);
00183     }
00184 }

void Thread::initAndRun (  )  [protected, inherited]

Definition at line 66 of file Thread.cpp.

References Thread::afterRun(), Thread::beforeRun(), and Thread::run().

Referenced by Thread::start().

00067 {
00068     beforeRun();
00069     run();
00070     afterRun();
00071 }

void Thread::beforeRun (  )  [protected, virtual, inherited]

Definition at line 73 of file Thread.cpp.

References Thread::bRunning.

Referenced by Thread::initAndRun().

00074 {
00075     bRunning = true;
00076 }

void Thread::afterRun (  )  [protected, virtual, inherited]

Definition at line 78 of file Thread.cpp.

References Thread::bRunning.

Referenced by Thread::initAndRun().

00079 {
00080     bRunning = false;
00081 }

void Thread::start (  )  [virtual, inherited]

Spawns the OS thread.

Definition at line 50 of file Thread.cpp.

References Thread::initAndRun(), and Thread::pBoostThread.

Referenced by AioLinuxScheduler::AioLinuxScheduler(), AioPollingScheduler::AioPollingScheduler(), StatsTimer::start(), ResourceTest::testConcurrency(), and LocalConditionTest::testNotifyAll().

00051 {
00052     pBoostThread = new boost::thread(
00053         boost::bind(&Thread::initAndRun,this));
00054 }

void Thread::join (  )  [inherited]

Waits for the OS thread to terminate.

Definition at line 56 of file Thread.cpp.

References Thread::pBoostThread.

Referenced by CheckpointThread::closeImpl(), TimerThread::stop(), AioPollingScheduler::stop(), AioLinuxScheduler::stop(), ResourceTest::testConcurrency(), and LocalConditionTest::testNotifyAll().

00057 {
00058     assert(pBoostThread);
00059     boost::thread t;
00060     assert(*pBoostThread != t);
00061     pBoostThread->join();
00062     delete pBoostThread;
00063     pBoostThread = NULL;
00064 }

bool Thread::isStarted (  )  const [inline, inherited]

Returns:
true if start has been called (and subsequent join has not completed)

Reimplemented in AioLinuxScheduler.

Definition at line 71 of file Thread.h.

Referenced by CheckpointThread::closeImpl(), CacheImpl< PageT, VictimPolicyT >::closeImpl(), AioLinuxScheduler::isStarted(), and TimerThread::stop().

00072     {
00073         return pBoostThread ? true : false;
00074     }

bool Thread::isStopped (  )  const [inline, inherited]

Returns:
opposite of isStarted()

Definition at line 79 of file Thread.h.

00080     {
00081         return !isStarted();
00082     }

boost::thread& Thread::getBoostThread (  )  [inline, inherited]

Accesses the underlying boost::thread, e.g.

for use in a boost::thread_group. This thread must already be started.

Returns:
the underlying boost::thread

Definition at line 90 of file Thread.h.

00091     {
00092         assert(isStarted());
00093         return *pBoostThread;
00094     }

std::string Thread::getName (  )  [inline, inherited]

Definition at line 96 of file Thread.h.

00097     {
00098         return name;
00099     }

void Thread::setName ( std::string const &  s  )  [inline, inherited]

Definition at line 101 of file Thread.h.

00102     {
00103         name = s;
00104     }


Member Data Documentation

AioSignalScheduler& AioSignalHandlerThread::scheduler [private]

Definition at line 40 of file AioSignalScheduler.cpp.

Referenced by run().

boost::thread* Thread::pBoostThread [protected, inherited]

Definition at line 44 of file Thread.h.

Referenced by Thread::join(), Thread::start(), Thread::Thread(), and Thread::~Thread().

bool Thread::bRunning [protected, inherited]

Definition at line 45 of file Thread.h.

Referenced by Thread::afterRun(), Thread::beforeRun(), Thread::Thread(), and Thread::~Thread().

std::string Thread::name [protected, inherited]

Definition at line 46 of file Thread.h.

Referenced by Thread::Thread().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:24 2009 for Fennel by  doxygen 1.5.1