ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::thread_affinity Class Reference

#include <thread_affinity.hpp>

Public Member Functions

 thread_affinity ()=default
 Construct an empty affinity set (no CPU pinning requested).
 
 thread_affinity (std::vector< cpu_id > cpus)
 Construct from a list of CPUs.
 
 thread_affinity (std::initializer_list< cpu_id > cpus)
 Construct from an initializer list of CPUs.
 
void add_cpu (cpu_id cpu)
 Add a CPU to the affinity set.
 
void remove_cpu (cpu_id cpu)
 Remove a CPU from the affinity set.
 
void clear () noexcept
 Remove all CPUs from the affinity set.
 
auto contains (cpu_id cpu) const noexcept -> bool
 Check whether a CPU is present in the affinity set.
 
auto empty () const noexcept -> bool
 Return whether the affinity set is empty.
 
auto cpus () const noexcept -> std::vector< cpu_id > const &
 Return the normalized sorted list of CPUs in the set.
 

Detailed Description

Definition at line 18 of file thread_affinity.hpp.

Constructor & Destructor Documentation

◆ thread_affinity() [1/3]

threadschedule::thread_affinity::thread_affinity ( )
default

Construct an empty affinity set (no CPU pinning requested).

◆ thread_affinity() [2/3]

threadschedule::thread_affinity::thread_affinity ( std::vector< cpu_id cpus)
inlineexplicit

Construct from a list of CPUs.

Parameters
cpusCPU identifiers; duplicates are removed and values are sorted.

Definition at line 27 of file thread_affinity.hpp.

◆ thread_affinity() [3/3]

threadschedule::thread_affinity::thread_affinity ( std::initializer_list< cpu_id cpus)
inline

Construct from an initializer list of CPUs.

Parameters
cpusCPU identifiers; duplicates are removed and values are sorted.

Definition at line 36 of file thread_affinity.hpp.

Member Function Documentation

◆ add_cpu()

void threadschedule::thread_affinity::add_cpu ( cpu_id  cpu)
inline

Add a CPU to the affinity set.

Parameters
cpuCPU to add.

Definition at line 46 of file thread_affinity.hpp.

References contains().

Referenced by threadschedule::advanced::affinity_for_node().

◆ clear()

void threadschedule::thread_affinity::clear ( )
inlinenoexcept

Remove all CPUs from the affinity set.

Definition at line 66 of file thread_affinity.hpp.

◆ contains()

auto threadschedule::thread_affinity::contains ( cpu_id  cpu) const -> bool
inlinenoexcept

Check whether a CPU is present in the affinity set.

Parameters
cpuCPU identifier to test.

Definition at line 76 of file thread_affinity.hpp.

Referenced by add_cpu().

◆ cpus()

auto threadschedule::thread_affinity::cpus ( ) const -> std::vector<cpu_id> const&
inlinenoexcept

Return the normalized sorted list of CPUs in the set.

Definition at line 90 of file thread_affinity.hpp.

◆ empty()

auto threadschedule::thread_affinity::empty ( ) const -> bool
inlinenoexcept

Return whether the affinity set is empty.

Definition at line 83 of file thread_affinity.hpp.

◆ remove_cpu()

void threadschedule::thread_affinity::remove_cpu ( cpu_id  cpu)
inline

Remove a CPU from the affinity set.

Parameters
cpuCPU to remove.

Definition at line 59 of file thread_affinity.hpp.


The documentation for this class was generated from the following file: