|
ThreadSchedule 3.0.0
Modern C++ thread management library
|
Manages a set of CPU indices to which a thread may be bound. More...
#include <native.hpp>
Public Member Functions | |
| native_thread_affinity () | |
| native_thread_affinity (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.
native_thread_affinity 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. native_thread_affinity 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 432 of file native.hpp.
|
inline |
Definition at line 435 of file native.hpp.
|
inlineexplicit |
Definition at line 445 of file native.hpp.
References add_cpu().
|
inline |
Definition at line 456 of file native.hpp.
Referenced by native_thread_affinity().
|
inline |
Definition at line 522 of file native.hpp.
|
inline |
Definition at line 532 of file native.hpp.
Referenced by to_string().
|
inline |
Definition at line 516 of file native.hpp.
References is_set().
|
inline |
Definition at line 502 of file native.hpp.
Referenced by has_cpu().
|
inline |
Definition at line 573 of file native.hpp.
|
inline |
Definition at line 482 of file native.hpp.
|
inline |
Definition at line 580 of file native.hpp.
References get_cpus().