ThreadSchedule 4.1.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 THREADSCHEDULE_LIFETIMEBOUND -> std::vector< cpu_id > const &
 Return the normalized sorted list of CPUs in the set.

Detailed Description

Definition at line 19 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 28 of file thread_affinity.hpp.

References cpus().

◆ 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 37 of file thread_affinity.hpp.

References cpus().

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 47 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 67 of file thread_affinity.hpp.

◆ contains()

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

Check whether a CPU is present in the affinity set.

Parameters
cpuCPU identifier to test.

Definition at line 77 of file thread_affinity.hpp.

Referenced by add_cpu().

◆ cpus()

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

Return the normalized sorted list of CPUs in the set.

Definition at line 91 of file thread_affinity.hpp.

References THREADSCHEDULE_LIFETIMEBOUND.

Referenced by thread_affinity(), and thread_affinity().

◆ empty()

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

Return whether the affinity set is empty.

Definition at line 84 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 60 of file thread_affinity.hpp.


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