Kea  1.5.0
threaded_test.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef THREADED_TEST_H
8 #define THREADED_TEST_H
9 
10 #include <util/threads/thread.h>
11 #include <util/threads/sync.h>
12 #include <boost/shared_ptr.hpp>
13 #include <gtest/gtest.h>
14 
15 namespace isc {
16 namespace test {
17 
23 class ThreadedTest : public ::testing::Test {
24 protected:
25 
27  ThreadedTest();
28 
33  void doSignal(bool& flag);
34 
36  void signalReady();
37 
39  void signalStopping();
40 
42  void signalStopped();
43 
48  void doWait(bool& flag);
49 
51  void waitReady();
52 
54  void waitStopping();
55 
57  void waitStopped();
58 
62  bool isStopping();
63 
65  boost::shared_ptr<util::thread::Thread> thread_;
66 
69 
72 
74  bool ready_;
75 
77  bool stopping_;
78 
80  bool stopped_;
81 };
82 
83 
84 } // end of namespace isc::test
85 } // end of namespace isc
86 
87 #endif
bool stopped_
Flag indicating that the thread is stopped.
Definition: threaded_test.h:80
void waitReady()
Wait for the thread to be ready.
void doWait(bool &flag)
Wait for a selected flag to be set.
bool stopping_
Flag indicating that the thread is stopping.
Definition: threaded_test.h:77
void waitStopping()
Wait for the thread to be stopping.
void doSignal(bool &flag)
Sets selected flag to true and signals condition variable.
ThreadedTest()
Constructor.
void waitStopped()
Wait for the thread to stop.
void signalReady()
Signal that thread is ready.
util::thread::Mutex mutex_
Mutex used to synchronize threads.
Definition: threaded_test.h:68
Encapsulation for a condition variable.
Definition: sync.h:205
bool ready_
Flag indicating that the thread is ready.
Definition: threaded_test.h:74
Defines the logger used by the top-level component of kea-dhcp-ddns.
Mutex with very simple interface.
Definition: sync.h:39
util::thread::CondVar condvar_
Condtional variable for thread waits.
Definition: threaded_test.h:71
void signalStopped()
Signal that thread is stopped.
void signalStopping()
Signal that thread is stopping.
Base class for tests requiring threads.
Definition: threaded_test.h:23
boost::shared_ptr< util::thread::Thread > thread_
Pointer to server thread.
Definition: threaded_test.h:65
bool isStopping()
Checks if the thread is stopping.