// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <testutils/threaded_test.h>
namespace isc {
namespace test {
ThreadedTest::ThreadedTest()
: thread_(), condvar_(), ready_(false), stopping_(false),
stopped_(false) {
}
void
ThreadedTest::doSignal(bool& flag) {
{
std::lock_guard<std::mutex> lock(mutex_);
flag = true;
}
condvar_.notify_one();
}
void
ThreadedTest::signalReady() {<--- The function 'signalReady' is never used.
doSignal(ready_);
}
void
ThreadedTest::signalStopping() {<--- The function 'signalStopping' is never used.
doSignal(stopping_);
}
void
ThreadedTest::signalStopped() {<--- The function 'signalStopped' is never used.
doSignal(stopped_);
}
void
ThreadedTest::doWait(bool& flag) {<--- Parameter 'flag' can be declared as reference to const
std::unique_lock<std::mutex> lock(mutex_);
while (!flag) {
condvar_.wait(lock);
}
}
void
ThreadedTest::waitReady() {<--- The function 'waitReady' is never used.
doWait(ready_);
}
void
ThreadedTest::waitStopping() {<--- The function 'waitStopping' is never used.
doWait(stopping_);
}
void
ThreadedTest::waitStopped() {<--- The function 'waitStopped' is never used.
doWait(stopped_);
}
bool
ThreadedTest::isStopping() {<--- The function 'isStopping' is never used.
std::lock_guard<std::mutex> lock(mutex_);
return (stopping_);
}
} // end of namespace isc::test
} // end of namespace isc