Kea 3.1.9
multi_threading_utils.h
Go to the documentation of this file.
1// Copyright (C) 2020-2026 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 MULTI_THREADING_UTILS_H
8#define MULTI_THREADING_UTILS_H
9
11
12namespace isc {
13namespace test {
14
23bool inline checkTryLock(std::mutex& mutex) {
24 bool locked = true;
25 auto f = [&]() {
26 if (mutex.try_lock()) {
27 mutex.unlock();
28 locked = false;
29 }
30 };
31 std::thread th(f);
32 th.join();
33 return (!locked);
34}
35
55
56} // end of isc::test namespace
57} // end of isc namespace
58
59#endif // MULTI_THREADING_UTILS_H
~MultiThreadingTest()
Destructor (disable multi threading).
MultiThreadingTest(bool mode=true)
Constructor (set multi threading mode).
void setMode(bool enabled)
Set the multi-threading mode.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
bool checkTryLock(std::mutex &mutex)
Check if mutex is locked.
Defines the logger used by the top-level component of kea-lfc.