Kea  1.9.9-git
isc::test::ThreadedTest Class Reference

Base class for tests requiring threads. More...

#include <threaded_test.h>

+ Inheritance diagram for isc::test::ThreadedTest:

Protected Member Functions

 ThreadedTest ()
 Constructor. More...
 
void doSignal (bool &flag)
 Sets selected flag to true and signals condition variable. More...
 
void doWait (bool &flag)
 Wait for a selected flag to be set. More...
 
bool isStopping ()
 Checks if the thread is stopping. More...
 
void signalReady ()
 Signal that thread is ready. More...
 
void signalStopped ()
 Signal that thread is stopped. More...
 
void signalStopping ()
 Signal that thread is stopping. More...
 
void waitReady ()
 Wait for the thread to be ready. More...
 
void waitStopped ()
 Wait for the thread to stop. More...
 
void waitStopping ()
 Wait for the thread to be stopping. More...
 

Protected Attributes

std::condition_variable condvar_
 Conditional variable for thread waits. More...
 
std::mutex mutex_
 Mutex used to synchronize threads. More...
 
bool ready_
 Flag indicating that the thread is ready. More...
 
bool stopped_
 Flag indicating that the thread is stopped. More...
 
bool stopping_
 Flag indicating that the thread is stopping. More...
 
boost::shared_ptr< std::thread > thread_
 Pointer to server thread. More...
 

Detailed Description

Base class for tests requiring threads.

This class contains 3 flags to signal when the thread has started, is stopping and when it is stopped. The flags are accessed in thread safe manner.

Definition at line 24 of file threaded_test.h.

Constructor & Destructor Documentation

isc::test::ThreadedTest::ThreadedTest ( )
protected

Constructor.

Definition at line 14 of file threaded_test.cc.

Member Function Documentation

void isc::test::ThreadedTest::doSignal ( bool &  flag)
protected

Sets selected flag to true and signals condition variable.

Parameters
flagReference to flag which should be set to true.

Definition at line 20 of file threaded_test.cc.

References condvar_, and mutex_.

Referenced by signalReady(), signalStopped(), and signalStopping().

void isc::test::ThreadedTest::doWait ( bool &  flag)
protected

Wait for a selected flag to be set.

Parameters
flagReference to a flag on which the thread is waiting.

Definition at line 44 of file threaded_test.cc.

References condvar_, and mutex_.

Referenced by waitReady(), waitStopped(), and waitStopping().

bool isc::test::ThreadedTest::isStopping ( )
protected

Checks if the thread is stopping.

Returns
true if the thread is stopping, false otherwise.

Definition at line 67 of file threaded_test.cc.

References mutex_, and stopping_.

void isc::test::ThreadedTest::signalReady ( )
protected

Signal that thread is ready.

Definition at line 29 of file threaded_test.cc.

References doSignal(), and ready_.

+ Here is the call graph for this function:

void isc::test::ThreadedTest::signalStopped ( )
protected

Signal that thread is stopped.

Definition at line 39 of file threaded_test.cc.

References doSignal(), and stopped_.

+ Here is the call graph for this function:

void isc::test::ThreadedTest::signalStopping ( )
protected

Signal that thread is stopping.

Definition at line 34 of file threaded_test.cc.

References doSignal(), and stopping_.

+ Here is the call graph for this function:

void isc::test::ThreadedTest::waitReady ( )
protected

Wait for the thread to be ready.

Definition at line 52 of file threaded_test.cc.

References doWait(), and ready_.

+ Here is the call graph for this function:

void isc::test::ThreadedTest::waitStopped ( )
protected

Wait for the thread to stop.

Definition at line 62 of file threaded_test.cc.

References doWait(), and stopped_.

+ Here is the call graph for this function:

void isc::test::ThreadedTest::waitStopping ( )
protected

Wait for the thread to be stopping.

Definition at line 57 of file threaded_test.cc.

References doWait(), and stopping_.

+ Here is the call graph for this function:

Member Data Documentation

std::condition_variable isc::test::ThreadedTest::condvar_
protected

Conditional variable for thread waits.

Definition at line 72 of file threaded_test.h.

Referenced by doSignal(), and doWait().

std::mutex isc::test::ThreadedTest::mutex_
protected

Mutex used to synchronize threads.

Definition at line 69 of file threaded_test.h.

Referenced by doSignal(), doWait(), and isStopping().

bool isc::test::ThreadedTest::ready_
protected

Flag indicating that the thread is ready.

Definition at line 75 of file threaded_test.h.

Referenced by signalReady(), and waitReady().

bool isc::test::ThreadedTest::stopped_
protected

Flag indicating that the thread is stopped.

Definition at line 81 of file threaded_test.h.

Referenced by signalStopped(), and waitStopped().

bool isc::test::ThreadedTest::stopping_
protected

Flag indicating that the thread is stopping.

Definition at line 78 of file threaded_test.h.

Referenced by isStopping(), signalStopping(), and waitStopping().

boost::shared_ptr<std::thread> isc::test::ThreadedTest::thread_
protected

Pointer to server thread.

Definition at line 66 of file threaded_test.h.


The documentation for this class was generated from the following files: