|
ThreadSchedule 3.0.0
Modern C++ thread management library
|
Namespaces | |
| namespace | error_handler_detail |
| namespace | profile_detail |
| namespace | profiles |
| namespace | topology_detail |
Classes | |
| struct | chaos_config |
| class | chaos_controller |
| class | composite_thread_registry |
| Non-owning facade that merges snapshots from multiple registries. More... | |
| struct | cpu_topology |
| Snapshot of basic CPU/NUMA topology. More... | |
| class | error_handled_task |
| Callable wrapper that catches exceptions and routes them to an error_handler. More... | |
| class | error_handler |
| Central registry and dispatcher for task-error callbacks. More... | |
| class | future_with_error_handler |
| A move-only future wrapper that supports an error callback. More... | |
| class | global_thread_pool |
| class | global_work_stealing_pool |
| class | inline_pool |
| class | lightweight_pool |
| class | polling_pool |
| class | raw_scheduled_pool |
| class | raw_thread_pool |
| class | scheduled_lightweight_pool |
| class | scheduled_polling_pool |
| class | scheduled_work_stealing_pool |
| class | task_group |
| Scoped task group that ensures all submitted work completes before the group is destroyed. More... | |
| class | thread_by_name_view |
| Non-owning control view found by an exact process-thread name. More... | |
| struct | thread_profile |
| class | work_stealing_pool |
Typedefs | |
| using | native_thread_id = pid_t |
Functions | |
| auto | cgroup_attach_tid (std::string const &cgroup_dir, native_thread_id tid) -> result< void > |
| Attach a native Linux thread ID to a cgroup v1 or v2 directory. | |
| auto | read_topology () -> cpu_topology |
| Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, processor-group-aware CPU indices. | |
| auto | affinity_for_node (cpu_topology const &topo, int node_index, int thread_index, int threads_per_node=1) -> thread_affinity |
| Build a thread_affinity for the given NUMA node using a pre-read topology. | |
| auto | affinity_for_node (int node_index, int thread_index, int threads_per_node=1) -> thread_affinity |
| Build a thread_affinity for the given NUMA node. | |
| auto | distribute_affinities_by_numa (cpu_topology const &topo, size_t num_threads) -> std::vector< thread_affinity > |
| Distribute thread affinities across NUMA nodes in round-robin order. | |
| auto | distribute_affinities_by_numa (size_t num_threads) -> std::vector< thread_affinity > |
| Distribute thread affinities across NUMA nodes in round-robin order. | |
| template<typename Func > | |
| auto | make_error_handled_task (Func &&func, std::shared_ptr< error_handler > handler, std::string description="") |
| Factory function that creates an error_handled_task with perfect forwarding. | |
| template<typename T > | |
| auto | when_all (std::vector< std::future< T > > &futures) -> std::vector< T > |
| Block until all futures complete, returning results in submission order. | |
| void | when_all (std::vector< std::future< void > > &futures) |
| Block until all void futures complete. | |
| template<typename T > | |
| auto | when_all_settled (std::vector< std::future< T > > &futures) -> std::vector< expected< T, std::exception_ptr > > |
Block until all futures complete, returning an expected per slot. | |
| auto | when_all_settled (std::vector< std::future< void > > &futures) -> std::vector< expected< void, std::exception_ptr > > |
Block until all void futures complete, returning an expected per slot. | |
| template<typename T > | |
| auto | when_any (std::vector< std::future< T > > &futures) -> std::pair< size_t, T > |
| Block until the first future becomes ready. | |
| auto | when_any (std::vector< std::future< void > > &futures) -> size_t |
| Block until the first void future becomes ready. | |
| auto | native_handle (thread &value) -> std::thread::native_handle_type |
| auto | native_id (thread_id id) noexcept -> result< native_thread_id > |
| template<typename ThreadLike > | |
| auto | apply_profile (ThreadLike &value, thread_profile const &profile) -> result< void > |
| auto | apply_profile (raw_thread_pool &pool, thread_profile const &profile) -> result< void > |
| auto | apply_profile (polling_pool &pool, thread_profile const &profile) -> result< void > |
| auto | apply_profile (work_stealing_pool &pool, thread_profile const &profile) -> result< void > |
| template<typename ThreadLike > | |
| auto | apply_profile_detailed (ThreadLike &value, thread_profile const &profile) -> std::vector< std::error_code > |
| using threadschedule::advanced::native_thread_id = typedef pid_t |
Definition at line 61 of file native_thread.hpp.
|
inline |
Build a thread_affinity for the given NUMA node using a pre-read topology.
| topo | Pre-read topology snapshot. |
| node_index | NUMA node index (wraps if out of range). |
| thread_index | Used to select CPU(s) within the node. |
| threads_per_node | Number of CPUs to include per thread (default 1). |
Definition at line 210 of file cpu_topology.hpp.
References threadschedule::thread_affinity::add_cpu().
Referenced by affinity_for_node(), and distribute_affinities_by_numa().
|
inline |
Build a thread_affinity for the given NUMA node.
Calls read_topology() internally on every invocation (no caching).
| node_index | NUMA node index (wraps if out of range). |
| thread_index | Used to select CPU(s) within the node. |
| threads_per_node | Number of CPUs to include per thread (default 1). |
Definition at line 252 of file cpu_topology.hpp.
References affinity_for_node(), and read_topology().
|
inline |
Definition at line 95 of file thread_profile.hpp.
References threadschedule::advanced::profile_detail::apply_to_pool().
|
inline |
Definition at line 89 of file thread_profile.hpp.
References threadschedule::advanced::profile_detail::apply_to_pool().
| auto threadschedule::advanced::apply_profile | ( | ThreadLike & | value, |
| thread_profile const & | profile | ||
| ) | -> result<void> |
Definition at line 83 of file thread_profile.hpp.
References threadschedule::advanced::profile_detail::apply_to_thread().
|
inline |
Definition at line 101 of file thread_profile.hpp.
References threadschedule::advanced::profile_detail::apply_to_pool().
| auto threadschedule::advanced::apply_profile_detailed | ( | ThreadLike & | value, |
| thread_profile const & | profile | ||
| ) | -> std::vector<std::error_code> |
Definition at line 108 of file thread_profile.hpp.
References threadschedule::thread_config::set_name().
|
inline |
Attach a native Linux thread ID to a cgroup v1 or v2 directory.
operation_not_permitted when no supported control file can be written. Definition at line 25 of file cgroup.hpp.
|
inline |
Distribute thread affinities across NUMA nodes in round-robin order.
Uses a pre-read topology to avoid repeated sysfs access.
| topo | Pre-read topology snapshot. |
| num_threads | Number of affinity masks to generate. |
num_threads thread_affinity objects. Definition at line 267 of file cpu_topology.hpp.
References affinity_for_node().
Referenced by distribute_affinities_by_numa().
|
inline |
Distribute thread affinities across NUMA nodes in round-robin order.
Returns one thread_affinity per thread, cycling through NUMA nodes so that consecutive threads are spread across different nodes.
| num_threads | Number of affinity masks to generate. |
num_threads thread_affinity objects. Definition at line 289 of file cpu_topology.hpp.
References distribute_affinities_by_numa(), and read_topology().
| auto threadschedule::advanced::make_error_handled_task | ( | Func && | func, |
| std::shared_ptr< error_handler > | handler, | ||
| std::string | description = "" |
||
| ) |
Factory function that creates an error_handled_task with perfect forwarding.
| Func | Callable type (deduced). |
| func | The callable to wrap. |
| handler | Shared pointer to the error_handler that will receive errors. |
| description | Optional human-readable label stored in task_error::task_description. |
func. Definition at line 257 of file error_handler.hpp.
|
inline |
Definition at line 45 of file native_thread.hpp.
|
inlinenoexcept |
Definition at line 65 of file native_thread.hpp.
References threadschedule::detail::thread_id_access::value().
|
inline |
Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, processor-group-aware CPU indices.
Called frequently by chaos/affinity helpers. The result is not cached internally - consider caching the returned cpu_topology yourself if performance of repeated calls matters.
Definition at line 123 of file cpu_topology.hpp.
References threadschedule::advanced::cpu_topology::cpu_count, threadschedule::advanced::cpu_topology::node_to_cpus, threadschedule::advanced::cpu_topology::numa_nodes, and threadschedule::advanced::topology_detail::read_index_list().
Referenced by affinity_for_node(), and distribute_affinities_by_numa().
| auto threadschedule::advanced::when_all | ( | std::vector< std::future< T > > & | futures | ) | -> std::vector<T> |
Block until all futures complete, returning results in submission order.
If any future throws, the first exception is captured and re-thrown after all remaining futures have been waited on (to avoid leaving them dangling).
| T | The value type of each future. |
| futures | A vector of futures to wait on. Moved-from on return. |
Definition at line 39 of file futures.hpp.
|
inline |
Block until all void futures complete.
Re-throws the first exception after all futures have been waited on.
Definition at line 70 of file futures.hpp.
| auto threadschedule::advanced::when_all_settled | ( | std::vector< std::future< T > > & | futures | ) | -> std::vector<expected<T, std::exception_ptr>> |
Block until all futures complete, returning an expected per slot.
Never throws. Each slot is either the result value or the captured std::exception_ptr.
| T | The value type of each future. |
Definition at line 101 of file futures.hpp.
|
inline |
Block until all void futures complete, returning an expected per slot.
Definition at line 126 of file futures.hpp.
| auto threadschedule::advanced::when_any | ( | std::vector< std::future< T > > & | futures | ) | -> std::pair<size_t, T> |
Block until the first future becomes ready.
Polls all futures round-robin with a 1 ms timeout until one is ready, then returns its index and value.
get().| T | The value type of each future. |
Definition at line 163 of file futures.hpp.
|
inline |
Block until the first void future becomes ready.
| std::invalid_argument | If futures is empty. |
Definition at line 200 of file futures.hpp.