ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
this_thread.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "thread_config.hpp"
6
7#include <string>
8
9namespace threadschedule
10{
12namespace this_thread
13{
17inline auto
19{
20 auto current = detail::thread_info();
21 return detail::portable_thread_control::configure(current, config);
22}
23
25inline auto
27{
28 auto current = detail::thread_info();
29 return detail::portable_thread_control::set_priority(current, level);
30}
31
33inline auto
35{
36 auto current = detail::thread_info();
37 return detail::portable_thread_control::set_nice(current, value);
38}
39
41[[nodiscard]] inline auto
43{
44 auto const id = detail::current_native_thread_id();
45 return detail::portable_thread_control::get_priority(detail::read_effective_nice(id, id));
46}
47
49[[nodiscard]] inline auto
51{
52 auto const id = detail::current_native_thread_id();
53 return detail::portable_thread_control::get_nice(detail::read_effective_nice(id, id));
54}
55
57inline auto
58set_name(std::string const& name) -> result<void>
59{
60 return detail::thread_info().set_name(name);
61}
62
64[[nodiscard]] inline auto
69
71inline auto
73{
74 auto current = detail::thread_info();
75 return detail::portable_thread_control::set_affinity(current, affinity);
76}
77
79[[nodiscard]] inline auto
81{
82 return detail::portable_thread_control::get_affinity(detail::thread_info().get_affinity());
83}
84} // namespace this_thread
85
86} // namespace threadschedule
Lightweight handle for querying and controlling a specific OS thread.
auto get_name() const -> expected< std::string, std::error_code >
auto set_name(std::string const &name) const -> expected< void, std::error_code >
Strongly-typed nice value in the POSIX range $[-20, 19]$.
Portable thread configuration bundle.
auto read_effective_nice(NativeHandle handle, native_thread_id tid) -> expected< int, std::error_code >
Definition native.hpp:847
auto current_native_thread_id() noexcept -> native_thread_id
auto get_nice() -> result< nice_value >
Query current nice value of the calling thread.
auto set_name(std::string const &name) -> result< void >
Set the calling thread name.
auto get_affinity() -> result< thread_affinity >
Query CPU affinity of the calling thread.
auto configure(thread_config const &config) -> result< void >
Apply full portable configuration to the calling thread.
auto get_priority() -> result< priority_level >
Query current portable priority preset of the calling thread.
auto set_nice(nice_value value) -> result< void >
Set explicit nice value for the calling thread.
auto set_priority(priority_level level) -> result< void >
Set portable priority preset for the calling thread.
auto set_affinity(thread_affinity const &affinity) -> result< void >
Set CPU affinity for the calling thread.
auto get_name() -> result< std::string >
Query the calling thread name.
priority_level
Portable non-realtime priority levels.
C++17 thread wrappers and non-owning views.
Portable thread startup and runtime configuration.