ThreadSchedule 2.2.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::detail Namespace Reference

Classes

class  function_ref
class  function_ref< R(Args...)>
struct  NonOwningTag
 Tag type selecting non-owning (pointer) storage in ThreadStorage. More...
struct  OwningTag
 Tag type selecting owning (value) storage in ThreadStorage. More...
class  QueryFacadeMixin
 CRTP mixin that provides functional-style query facade methods. More...
class  SboCallable
 Type-erased, move-only callable with configurable inline storage. More...
class  ThreadStorage
class  ThreadStorage< ThreadType, NonOwningTag >
 Non-owning thread storage - holds a raw pointer to an external thread. More...
class  ThreadStorage< ThreadType, OwningTag >
 Owning thread storage - holds the thread object by value. More...

Typedefs

template<typename T>
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>
template<typename Signature>
using move_callable = std::function<Signature>
template<typename Signature>
using copyable_callable = std::function<Signature>

Functions

template<typename Signature, typename Callable>
auto make_move_callable (Callable &&callable) -> move_callable< Signature >
template<typename Signature, typename Callable>
auto make_copyable_callable (Callable &&callable) -> copyable_callable< Signature >
template<typename T>
auto apply_profile_to (T &t, ThreadProfile const &p) -> expected< void, std::error_code >
 Apply policy + optional affinity to any type exposing set_scheduling_policy() and set_affinity().
template<typename PoolType>
auto apply_profile_to_pool (PoolType &pool, std::string const &name_prefix, ThreadProfile const &p) -> expected< void, std::error_code >
 Apply configure_threads + optional affinity to any pool type.
template<typename SetSchedFn>
auto apply_sched_params (SchedulingPolicy policy, ThreadPriority priority, SetSchedFn &&set_sched) -> expected< void, std::error_code >
auto apply_scheduling_policy (pthread_t handle, SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code >
auto apply_priority (pthread_t handle, ThreadPriority priority) -> expected< void, std::error_code >
auto apply_affinity (pthread_t handle, ThreadAffinity const &affinity) -> expected< void, std::error_code >
auto apply_name (pthread_t handle, std::string const &name) -> expected< void, std::error_code >
auto read_name (pthread_t handle) -> std::optional< std::string >
auto read_affinity (pthread_t handle) -> std::optional< ThreadAffinity >
auto read_priority (pthread_t handle) -> std::optional< int >
auto read_scheduling_policy (pthread_t handle) -> std::optional< SchedulingPolicy >
auto apply_scheduling_policy (pid_t tid, SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code >
auto apply_priority (pid_t tid, ThreadPriority priority) -> expected< void, std::error_code >
auto apply_affinity (pid_t tid, ThreadAffinity const &affinity) -> expected< void, std::error_code >
auto apply_name (pid_t tid, std::string const &name) -> expected< void, std::error_code >
auto read_name (pid_t tid) -> std::optional< std::string >
auto read_affinity (pid_t tid) -> std::optional< ThreadAffinity >
auto read_priority (pid_t tid) -> std::optional< int >
auto read_scheduling_policy (pid_t tid) -> std::optional< SchedulingPolicy >
template<typename WorkerRange>
auto configure_worker_threads (WorkerRange &workers, std::string const &name_prefix, SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code >
template<typename WorkerRange>
auto set_worker_affinity (WorkerRange &workers, ThreadAffinity const &affinity) -> expected< void, std::error_code >
template<typename WorkerRange>
auto distribute_workers_across_cpus (WorkerRange &workers) -> expected< void, std::error_code >
template<typename Pool, typename Iterator, typename F>
void parallel_for_each_chunked (Pool &pool, Iterator begin, Iterator end, F &&func, size_t num_workers)
template<typename F, typename... Args>
auto bind_args (F &&f, Args &&... args)
 Bind a callable with its arguments into a nullary lambda.
template<typename ThreadLike>
auto configure_thread (ThreadLike &thread, std::string const &name, SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code >

Typedef Documentation

◆ copyable_callable

template<typename Signature>
using threadschedule::detail::copyable_callable = std::function<Signature>

Definition at line 40 of file callable.hpp.

◆ move_callable

template<typename Signature>
using threadschedule::detail::move_callable = std::function<Signature>

Definition at line 32 of file callable.hpp.

◆ remove_cvref_t

template<typename T>
using threadschedule::detail::remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>

Definition at line 25 of file callable.hpp.

Function Documentation

◆ apply_affinity() [1/2]

auto threadschedule::detail::apply_affinity ( pid_t tid,
ThreadAffinity const & affinity ) -> expected<void, std::error_code>
inline

Definition at line 853 of file scheduler_policy.hpp.

◆ apply_affinity() [2/2]

◆ apply_name() [1/2]

auto threadschedule::detail::apply_name ( pid_t tid,
std::string const & name ) -> expected<void, std::error_code>
inline

Definition at line 860 of file scheduler_policy.hpp.

◆ apply_name() [2/2]

◆ apply_priority() [1/2]

auto threadschedule::detail::apply_priority ( pid_t tid,
ThreadPriority priority ) -> expected<void, std::error_code>
inline

Definition at line 848 of file scheduler_policy.hpp.

References apply_scheduling_policy(), and threadschedule::OTHER.

◆ apply_priority() [2/2]

◆ apply_profile_to()

template<typename T>
auto threadschedule::detail::apply_profile_to ( T & t,
ThreadProfile const & p ) -> expected<void, std::error_code>
inline

Apply policy + optional affinity to any type exposing set_scheduling_policy() and set_affinity().

Definition at line 115 of file profiles.hpp.

Referenced by threadschedule::apply_profile(), and threadschedule::apply_profile().

◆ apply_profile_to_pool()

template<typename PoolType>
auto threadschedule::detail::apply_profile_to_pool ( PoolType & pool,
std::string const & name_prefix,
ThreadProfile const & p ) -> expected<void, std::error_code>
inline

Apply configure_threads + optional affinity to any pool type.

Definition at line 134 of file profiles.hpp.

Referenced by threadschedule::apply_profile(), threadschedule::apply_profile(), and threadschedule::apply_profile().

◆ apply_sched_params()

template<typename SetSchedFn>
auto threadschedule::detail::apply_sched_params ( SchedulingPolicy policy,
ThreadPriority priority,
SetSchedFn && set_sched ) -> expected<void, std::error_code>
inline

◆ apply_scheduling_policy() [1/2]

auto threadschedule::detail::apply_scheduling_policy ( pid_t tid,
SchedulingPolicy policy,
ThreadPriority priority ) -> expected<void, std::error_code>
inline

Definition at line 841 of file scheduler_policy.hpp.

References apply_sched_params().

◆ apply_scheduling_policy() [2/2]

◆ bind_args()

template<typename F, typename... Args>
auto threadschedule::detail::bind_args ( F && f,
Args &&... args )

Bind a callable with its arguments into a nullary lambda.

On C++20 and later this uses pack init-captures for zero intermediate storage overhead. On C++17 it falls back to std::make_tuple / std::apply which is still significantly faster than std::bind.

Definition at line 131 of file thread_pool.hpp.

Referenced by threadschedule::HighPerformancePool::try_post(), threadschedule::LightweightPoolT< TaskSize >::try_post(), threadschedule::ThreadPoolBase< IndefiniteWait >::try_post(), threadschedule::HighPerformancePool::try_submit(), and threadschedule::ThreadPoolBase< IndefiniteWait >::try_submit().

◆ configure_thread()

template<typename ThreadLike>
auto threadschedule::detail::configure_thread ( ThreadLike & thread,
std::string const & name,
SchedulingPolicy policy,
ThreadPriority priority ) -> expected<void, std::error_code>
inline

◆ configure_worker_threads()

template<typename WorkerRange>
auto threadschedule::detail::configure_worker_threads ( WorkerRange & workers,
std::string const & name_prefix,
SchedulingPolicy policy,
ThreadPriority priority ) -> expected<void, std::error_code>
inline

◆ distribute_workers_across_cpus()

template<typename WorkerRange>
auto threadschedule::detail::distribute_workers_across_cpus ( WorkerRange & workers) -> expected<void, std::error_code>
inline

◆ make_copyable_callable()

◆ make_move_callable()

◆ parallel_for_each_chunked()

template<typename Pool, typename Iterator, typename F>
void threadschedule::detail::parallel_for_each_chunked ( Pool & pool,
Iterator begin,
Iterator end,
F && func,
size_t num_workers )
inline

◆ read_affinity() [1/2]

auto threadschedule::detail::read_affinity ( pid_t tid) -> std::optional<ThreadAffinity>
inline

Definition at line 891 of file scheduler_policy.hpp.

◆ read_affinity() [2/2]

auto threadschedule::detail::read_affinity ( pthread_t handle) -> std::optional<ThreadAffinity>
inline

◆ read_name() [1/2]

auto threadschedule::detail::read_name ( pid_t tid) -> std::optional<std::string>
inline

Definition at line 877 of file scheduler_policy.hpp.

◆ read_name() [2/2]

auto threadschedule::detail::read_name ( pthread_t handle) -> std::optional<std::string>
inline

◆ read_priority() [1/2]

auto threadschedule::detail::read_priority ( pid_t tid) -> std::optional<int>
inline

Definition at line 907 of file scheduler_policy.hpp.

◆ read_priority() [2/2]

auto threadschedule::detail::read_priority ( pthread_t handle) -> std::optional<int>
inline

Definition at line 821 of file scheduler_policy.hpp.

Referenced by threadschedule::ThreadInfo::get_priority().

◆ read_scheduling_policy() [1/2]

auto threadschedule::detail::read_scheduling_policy ( pid_t tid) -> std::optional<SchedulingPolicy>
inline

Definition at line 915 of file scheduler_policy.hpp.

◆ read_scheduling_policy() [2/2]

auto threadschedule::detail::read_scheduling_policy ( pthread_t handle) -> std::optional<SchedulingPolicy>
inline

Definition at line 830 of file scheduler_policy.hpp.

Referenced by threadschedule::ThreadInfo::get_policy().

◆ set_worker_affinity()

template<typename WorkerRange>
auto threadschedule::detail::set_worker_affinity ( WorkerRange & workers,
ThreadAffinity const & affinity ) -> expected<void, std::error_code>
inline