Kea 2.7.5
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.
 
void doSignal (bool &flag)
 Sets selected flag to true and signals condition variable.
 
void doWait (bool &flag)
 Wait for a selected flag to be set.
 
bool isStopping ()
 Checks if the thread is stopping.
 
void signalReady ()
 Signal that thread is ready.
 
void signalStopped ()
 Signal that thread is stopped.
 
void signalStopping ()
 Signal that thread is stopping.
 
void waitReady ()
 Wait for the thread to be ready.
 
void waitStopped ()
 Wait for the thread to stop.
 
void waitStopping ()
 Wait for the thread to be stopping.
 

Protected Attributes

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

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

◆ ThreadedTest()

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

Constructor.

Definition at line 14 of file threaded_test.cc.

Member Function Documentation

◆ doSignal()

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().

◆ doWait()

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().

◆ isStopping()

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_.

◆ signalReady()

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:

◆ signalStopped()

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:

◆ signalStopping()

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:

◆ waitReady()

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:

◆ waitStopped()

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:

◆ waitStopping()

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

◆ condvar_

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().

◆ mutex_

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().

◆ ready_

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().

◆ stopped_

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().

◆ stopping_

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().

◆ thread_

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: