ThreadSchedule 4.1.0
Modern C++ thread management library
Loading...
Searching...
No Matches
native.hpp File Reference

Scheduling policies, thread priority, and CPU affinity types. More...

#include "../../expected.hpp"
#include <algorithm>
#include <array>
#include <atomic>
#include <cstdint>
#include <fstream>
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include <system_error>
#include <vector>
#include <pthread.h>
#include <sched.h>
#include <sys/resource.h>
#include <sys/types.h>
#include "posix.hpp"
Include dependency graph for native.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  threadschedule::detail::native_thread_priority
 Value-semantic wrapper for a thread scheduling priority. More...
struct  threadschedule::detail::native_scheduling_config
struct  threadschedule::detail::resolved_scheduling
class  threadschedule::detail::native_thread_affinity
 Manages a set of CPU indices to which a thread may be bound. More...
struct  threadschedule::detail::native_thread_config
class  threadschedule::detail::scheduler_parameters
 Static utility class for constructing OS-native scheduling parameters. More...

Namespaces

namespace  threadschedule
namespace  threadschedule::detail
 Aggregates multiple thread_registry_backend instances into a single queryable view.
namespace  threadschedule::detail::native_schedule

Typedefs

using threadschedule::detail::native_thread_id = pid_t

Enumerations

enum class  threadschedule::detail::native_scheduling_policy : std::uint_fast8_t {
  threadschedule::detail::other = SCHED_OTHER , threadschedule::detail::fifo = SCHED_FIFO , threadschedule::detail::rr = SCHED_RR , threadschedule::detail::batch = SCHED_BATCH ,
  threadschedule::detail::idle = SCHED_IDLE
}
 Enumeration of available thread scheduling policies. More...
enum class  threadschedule::detail::native_scheduling_intent : std::uint_fast8_t {
  threadschedule::detail::background , threadschedule::detail::normal , threadschedule::detail::interactive , threadschedule::detail::low_latency ,
  threadschedule::detail::realtime
}
enum class  threadschedule::detail::native_priority_model : std::uint_fast8_t {
  threadschedule::detail::intent , threadschedule::detail::posix_nice , threadschedule::detail::posix_realtime , threadschedule::detail::windows_thread ,
  threadschedule::detail::platform_native
}

Functions

constexpr auto threadschedule::detail::native_schedule::background () noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::normal () noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::interactive () noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::low_latency () noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::realtime_fifo (int priority=80) noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::realtime_rr (int priority=80) noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::posix_nice (int nice_value) noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::native (native_scheduling_policy policy, native_thread_priority priority) noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::native_schedule::native_windows_priority (int priority) noexcept -> native_scheduling_config
constexpr auto threadschedule::detail::is_realtime_policy (native_scheduling_policy policy) noexcept -> bool
constexpr auto threadschedule::detail::uses_nice_value (native_scheduling_policy policy) noexcept -> bool
constexpr auto threadschedule::detail::resolve_scheduling_config (native_scheduling_config const &config) noexcept -> resolved_scheduling
auto threadschedule::detail::to_string (native_scheduling_policy policy) -> std::string
 String conversion utilities.
auto threadschedule::detail::pthread_call_result (int result) -> expected< void, std::error_code >
template<typename SetSchedFn>
auto threadschedule::detail::apply_sched_params (native_scheduling_policy policy, native_thread_priority priority, SetSchedFn &&set_sched) -> expected< void, std::error_code >
auto threadschedule::detail::apply_scheduling_policy (pthread_t handle, native_scheduling_policy policy, native_thread_priority priority) -> expected< void, std::error_code >
auto threadschedule::detail::apply_affinity (pthread_t handle, native_thread_affinity const &affinity) -> expected< void, std::error_code >
auto threadschedule::detail::apply_name (pthread_t handle, std::string const &name) -> expected< void, std::error_code >
auto threadschedule::detail::read_name (pthread_t handle) -> expected< std::string, std::error_code >
auto threadschedule::detail::read_affinity (pthread_t handle) -> expected< native_thread_affinity, std::error_code >
auto threadschedule::detail::read_priority (pthread_t handle) -> std::optional< int >
auto threadschedule::detail::read_scheduling_policy (pthread_t handle) -> std::optional< native_scheduling_policy >
auto threadschedule::detail::apply_scheduling_policy (pid_t tid, native_scheduling_policy policy, native_thread_priority priority) -> expected< void, std::error_code >
auto threadschedule::detail::apply_nice_value (pid_t tid, int nice_value) -> expected< void, std::error_code >
auto threadschedule::detail::apply_affinity (pid_t tid, native_thread_affinity const &affinity) -> expected< void, std::error_code >
auto threadschedule::detail::apply_name (pid_t tid, std::string const &name) -> expected< void, std::error_code >
auto threadschedule::detail::read_name (pid_t tid) -> expected< std::string, std::error_code >
auto threadschedule::detail::read_affinity (pid_t tid) -> expected< native_thread_affinity, std::error_code >
auto threadschedule::detail::read_priority (pid_t tid) -> std::optional< int >
auto threadschedule::detail::read_nice_value (pid_t tid) -> expected< int, std::error_code >
auto threadschedule::detail::read_scheduling_policy (pid_t tid) -> std::optional< native_scheduling_policy >
template<typename NativeHandle>
auto threadschedule::detail::apply_affinity_checked (NativeHandle handle, native_thread_affinity const &affinity) -> expected< void, std::error_code >
template<typename NativeHandle>
auto threadschedule::detail::apply_scheduling_config (NativeHandle handle, native_thread_id tid, native_scheduling_config const &config) -> expected< void, std::error_code >
template<typename NativeHandle>
auto threadschedule::detail::read_effective_nice (NativeHandle handle, native_thread_id tid) -> expected< int, std::error_code >

Detailed Description

Scheduling policies, thread priority, and CPU affinity types.

Definition in file native.hpp.