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
15namespace isc {
16namespace test {
17
23class ThreadedTest : public ::testing::Test {
24protected:
25
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
78
81};
82
83
84} // end of namespace isc::test
85} // end of namespace isc
86
87#endif
Base class for tests requiring threads.
Definition: threaded_test.h:23
void doWait(bool &flag)
Wait for a selected flag to be set.
void doSignal(bool &flag)
Sets selected flag to true and signals condition variable.
bool ready_
Flag indicating that the thread is ready.
Definition: threaded_test.h:74
void waitStopped()
Wait for the thread to stop.
bool stopped_
Flag indicating that the thread is stopped.
Definition: threaded_test.h:80
boost::shared_ptr< util::thread::Thread > thread_
Pointer to server thread.
Definition: threaded_test.h:65
ThreadedTest()
Constructor.
void waitStopping()
Wait for the thread to be stopping.
void signalStopped()
Signal that thread is stopped.
bool stopping_
Flag indicating that the thread is stopping.
Definition: threaded_test.h:77
util::thread::CondVar condvar_
Condtional variable for thread waits.
Definition: threaded_test.h:71
bool isStopping()
Checks if the thread is stopping.
void waitReady()
Wait for the thread to be ready.
util::thread::Mutex mutex_
Mutex used to synchronize threads.
Definition: threaded_test.h:68
void signalStopping()
Signal that thread is stopping.
void signalReady()
Signal that thread is ready.
Encapsulation for a condition variable.
Definition: sync.h:205
Mutex with very simple interface.
Definition: sync.h:39
Defines the logger used by the top-level component of kea-dhcp-ddns.