ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
thread_config.hpp
Go to the documentation of this file.
1#pragma once
2
8#include "scheduling.hpp"
9#include "thread_affinity.hpp"
10
11#include <optional>
12#include <string>
13#include <utility>
14
15namespace threadschedule
16{
17
25{
26public:
27 thread_config() = default;
28
33 auto
34 set_name(std::string name) -> thread_config&
35 {
36 name_ = std::move(name);
37 return *this;
38 }
39
41 auto
43 {
44 name_.reset();
45 return *this;
46 }
47
52 auto
54 {
55 scheduling_ = scheduling;
56 return *this;
57 }
58
60 auto
62 {
63 scheduling_.reset();
64 return *this;
65 }
66
71 auto
73 {
74 affinity_ = std::move(affinity);
75 return *this;
76 }
77
79 auto
81 {
82 affinity_.reset();
83 return *this;
84 }
85
87 [[nodiscard]] auto
88 get_name() const noexcept -> std::optional<std::string> const&
89 {
90 return name_;
91 }
93 [[nodiscard]] auto
94 get_scheduling() const noexcept -> std::optional<scheduling_config> const&
95 {
96 return scheduling_;
97 }
99 [[nodiscard]] auto
100 get_affinity() const noexcept -> std::optional<thread_affinity> const&
101 {
102 return affinity_;
103 }
105 [[nodiscard]] auto
106 empty() const noexcept -> bool
107 {
108 return !name_ && !scheduling_ && !affinity_;
109 }
110
111private:
112 std::optional<std::string> name_;
113 std::optional<scheduling_config> scheduling_;
114 std::optional<thread_affinity> affinity_;
115};
116
117} // namespace threadschedule
Immutable scheduling request passed to thread creation/configuration APIs.
Portable thread configuration bundle.
auto get_name() const noexcept -> std::optional< std::string > const &
Return configured thread name if present.
auto clear_name() noexcept -> thread_config &
Clear previously configured thread name.
auto get_scheduling() const noexcept -> std::optional< scheduling_config > const &
Return configured scheduling request if present.
auto set_name(std::string name) -> thread_config &
Set thread name.
auto clear_affinity() noexcept -> thread_config &
Clear previously configured CPU affinity.
auto empty() const noexcept -> bool
Return whether no settings are currently configured.
auto set_affinity(thread_affinity affinity) -> thread_config &
Set CPU affinity mask.
auto clear_scheduling() noexcept -> thread_config &
Clear previously configured scheduling request.
auto set_scheduling(scheduling_config scheduling) noexcept -> thread_config &
Set scheduling configuration.
auto get_affinity() const noexcept -> std::optional< thread_affinity > const &
Return configured affinity set if present.
Portable scheduling intents and priority configuration.
Portable normalized CPU-affinity value type.