NUMA++ 0.11.0
Loading...
Searching...
No Matches
thread.hpp
Go to the documentation of this file.
1/**
2 * @file
3 * @copyright
4 * (c) Copyright ESO 2024
5 * All Rights Reserved
6 * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7 */
8#ifndef NUMAPP_DETAIL_THREAD_HPP
9#define NUMAPP_DETAIL_THREAD_HPP
10
11#include <condition_variable>
12#include <functional>
13#include <mutex>
14
16
17namespace numapp::detail {
18
19class ThreadInitializer {
20public:
21 ThreadInitializer(std::string_view name, NumaPolicies const& policies);
22
23 /**
24 * Wait for Initialize() to complete.
25 */
26 auto Wait() -> std::system_error const&;
27
28 /**
29 * Setup calling thread according to provided policies.
30 */
31 auto Initialize() -> std::error_code;
32
33private:
34 std::string_view m_name;
35 NumaPolicies const& m_policies;
36
37 std::optional<std::system_error> m_result;
38 std::condition_variable m_cond;
39 std::mutex m_mtx;
40 /**
41 * Lock used by thread owning ThreadInitializer which invokes Wait()
42 */
43 std::unique_lock<std::mutex> m_lck;
44};
45
46} // namespace numapp::detail
47
48#endif // NUMAPP_DETAIL_THREAD_HPP
Contains declarations for NumaPolicies.