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
isc::test::ThreadedTest::stopped_
bool stopped_
Flag indicating that the thread is stopped.
Definition: threaded_test.h:80
sync.h
isc::util::thread::Mutex
Mutex with very simple interface.
Definition: sync.h:39
isc::test::ThreadedTest::mutex_
util::thread::Mutex mutex_
Mutex used to synchronize threads.
Definition: threaded_test.h:68
isc::test::ThreadedTest::waitStopped
void waitStopped()
Wait for the thread to stop.
Definition: threaded_test.cc:62
isc::test::ThreadedTest::signalStopping
void signalStopping()
Signal that thread is stopping.
Definition: threaded_test.cc:34
isc::test::ThreadedTest::waitReady
void waitReady()
Wait for the thread to be ready.
Definition: threaded_test.cc:52
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::test::ThreadedTest::doWait
void doWait(bool &flag)
Wait for a selected flag to be set.
Definition: threaded_test.cc:44
isc::test::ThreadedTest::signalStopped
void signalStopped()
Signal that thread is stopped.
Definition: threaded_test.cc:39
isc::test::ThreadedTest::waitStopping
void waitStopping()
Wait for the thread to be stopping.
Definition: threaded_test.cc:57
isc::test::ThreadedTest
Base class for tests requiring threads.
Definition: threaded_test.h:23
isc::test::ThreadedTest::ThreadedTest
ThreadedTest()
Constructor.
Definition: threaded_test.cc:14
isc::test::ThreadedTest::isStopping
bool isStopping()
Checks if the thread is stopping.
Definition: threaded_test.cc:67
isc::test::ThreadedTest::condvar_
util::thread::CondVar condvar_
Condtional variable for thread waits.
Definition: threaded_test.h:71
isc::util::thread::CondVar
Encapsulation for a condition variable.
Definition: sync.h:205
isc::test::ThreadedTest::stopping_
bool stopping_
Flag indicating that the thread is stopping.
Definition: threaded_test.h:77
isc::test::ThreadedTest::ready_
bool ready_
Flag indicating that the thread is ready.
Definition: threaded_test.h:74
isc::test::ThreadedTest::signalReady
void signalReady()
Signal that thread is ready.
Definition: threaded_test.cc:29
thread.h
isc::test::ThreadedTest::thread_
boost::shared_ptr< util::thread::Thread > thread_
Pointer to server thread.
Definition: threaded_test.h:65
isc::test::ThreadedTest::doSignal
void doSignal(bool &flag)
Sets selected flag to true and signals condition variable.
Definition: threaded_test.cc:20