|
ThreadSchedule 2.0.0
Modern C++ thread management library
|
Manages a set of CPU indices to which a thread may be bound. More...
#include <scheduler_policy.hpp>
Public Member Functions | |
| ThreadAffinity () | |
| ThreadAffinity (std::vector< int > const &cpus) | |
| void | add_cpu (int cpu) |
| void | remove_cpu (int cpu) |
| auto | is_set (int cpu) const -> bool |
| auto | has_cpu (int cpu) const -> bool |
| void | clear () |
| auto | get_cpus () const -> std::vector< int > |
| auto | native_handle () const -> cpu_set_t const & |
| auto | to_string () const -> std::string |
Manages a set of CPU indices to which a thread may be bound.
ThreadAffinity is a value-semantic type that represents a CPU affinity mask. It abstracts away the platform-specific details of cpu_set_t (Linux) and processor-group bitmasks (Windows).
Backed by a cpu_set_t. Supports CPU indices in the range [0, CPU_SETSIZE) (typically 0-1023). The native_handle() accessor provides a const cpu_set_t& for direct use with pthread_setaffinity_np or sched_setaffinity.
Backed by a 64-bit bitmask plus a processor group index (WORD). Windows organises logical processors into groups of up to 64. This class supports a single group at a time: the group is determined by the first CPU added via add_cpu(). Subsequent calls to add_cpu() for CPUs that belong to a different group are silently ignored. Use get_group() and get_mask() to retrieve the platform-native values for SetThreadGroupAffinity.
None. ThreadAffinity is a plain value type with no internal synchronisation. Concurrent reads are safe; concurrent mutation (or a read concurrent with a write) requires external locking.
Implicitly copyable and movable (compiler-generated special members).
Definition at line 213 of file scheduler_policy.hpp.
|
inline |
Definition at line 216 of file scheduler_policy.hpp.
Referenced by ThreadAffinity().
|
inlineexplicit |
Definition at line 226 of file scheduler_policy.hpp.
References add_cpu(), and ThreadAffinity().
|
inline |
Definition at line 235 of file scheduler_policy.hpp.
Referenced by threadschedule::affinity_for_node(), and ThreadAffinity().
|
inline |
Definition at line 297 of file scheduler_policy.hpp.
|
inlinenodiscard |
Definition at line 306 of file scheduler_policy.hpp.
Referenced by to_string().
|
inlinenodiscard |
Definition at line 292 of file scheduler_policy.hpp.
References is_set().
|
inlinenodiscard |
Definition at line 279 of file scheduler_policy.hpp.
Referenced by has_cpu().
|
inlinenodiscard |
Definition at line 343 of file scheduler_policy.hpp.
|
inline |
Definition at line 260 of file scheduler_policy.hpp.
|
inlinenodiscard |
Definition at line 349 of file scheduler_policy.hpp.
References get_cpus().