Kea  1.5.0
threaded_test.cc
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 
8 
9 using namespace isc::util::thread;
10 
11 namespace isc {
12 namespace test {
13 
14 ThreadedTest::ThreadedTest()
15  : thread_(), condvar_(), ready_(false), stopping_(false),
16  stopped_(false) {
17 }
18 
19 void
21  {
22  Mutex::Locker lock(mutex_);
23  flag = true;
24  }
25  condvar_.signal();
26 }
27 
28 void
31 }
32 
33 void
36 }
37 
38 void
41 }
42 
43 void
44 ThreadedTest::doWait(bool& flag) {
45  Mutex::Locker lock(mutex_);
46  while (!flag) {
48  }
49 }
50 
51 void
53  doWait(ready_);
54 }
55 
56 void
59 }
60 
61 void
64 }
65 
66 bool
68  Mutex::Locker lock(mutex_);
69  return (stopping_);
70 }
71 
72 } // end of namespace isc::test
73 } // end of namespace isc
bool stopped_
Flag indicating that the thread is stopped.
Definition: threaded_test.h:80
void waitReady()
Wait for the thread to be ready.
void wait(Mutex &mutex)
Wait on the condition variable.
Definition: sync.cc:225
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.
void waitStopped()
Wait for the thread to stop.
void signalReady()
Signal that thread is ready.
This holds a lock on a Mutex.
Definition: sync.h:72
Wrappers for thread related functionality.
Definition: sync.cc:24
util::thread::Mutex mutex_
Mutex used to synchronize threads.
Definition: threaded_test.h:68
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.
util::thread::CondVar condvar_
Condtional variable for thread waits.
Definition: threaded_test.h:71
void signalStopped()
Signal that thread is stopped.
void signal()
Unblock a thread waiting for the condition variable.
Definition: sync.cc:242
void signalStopping()
Signal that thread is stopping.
bool isStopping()
Checks if the thread is stopping.