Kea
1.9.9-git
|
Base class for tests requiring threads. More...
#include <threaded_test.h>
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... | |
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.
|
protected |
Constructor.
Definition at line 14 of file threaded_test.cc.
|
protected |
Sets selected flag to true and signals condition variable.
flag | Reference 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().
|
protected |
Wait for a selected flag to be set.
flag | Reference 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().
|
protected |
Checks if the thread is stopping.
Definition at line 67 of file threaded_test.cc.
|
protected |
Signal that thread is ready.
Definition at line 29 of file threaded_test.cc.
References doSignal(), and ready_.
|
protected |
Signal that thread is stopped.
Definition at line 39 of file threaded_test.cc.
References doSignal(), and stopped_.
|
protected |
Signal that thread is stopping.
Definition at line 34 of file threaded_test.cc.
References doSignal(), and stopping_.
|
protected |
Wait for the thread to be ready.
Definition at line 52 of file threaded_test.cc.
References doWait(), and ready_.
|
protected |
Wait for the thread to stop.
Definition at line 62 of file threaded_test.cc.
References doWait(), and stopped_.
|
protected |
Wait for the thread to be stopping.
Definition at line 57 of file threaded_test.cc.
References doWait(), and stopping_.
|
protected |
Conditional variable for thread waits.
Definition at line 72 of file threaded_test.h.
Referenced by doSignal(), and doWait().
|
protected |
Mutex used to synchronize threads.
Definition at line 69 of file threaded_test.h.
Referenced by doSignal(), doWait(), and isStopping().
|
protected |
Flag indicating that the thread is ready.
Definition at line 75 of file threaded_test.h.
Referenced by signalReady(), and waitReady().
|
protected |
Flag indicating that the thread is stopped.
Definition at line 81 of file threaded_test.h.
Referenced by signalStopped(), and waitStopped().
|
protected |
Flag indicating that the thread is stopping.
Definition at line 78 of file threaded_test.h.
Referenced by isStopping(), signalStopping(), and waitStopping().
|
protected |
Pointer to server thread.
Definition at line 66 of file threaded_test.h.