11#include <initializer_list>
51 std::sort(cpus_.begin(), cpus_.end());
61 cpus_.erase(std::remove(cpus_.begin(), cpus_.end(), cpu), cpus_.end());
78 return std::binary_search(cpus_.begin(), cpus_.end(), cpu);
99 std::sort(cpus_.begin(), cpus_.end());
100 cpus_.erase(std::unique(cpus_.begin(), cpus_.end()), cpus_.end());
103 std::vector<cpu_id> cpus_;
Validated CPU identifier.
void remove_cpu(cpu_id cpu)
Remove a CPU from the affinity set.
thread_affinity(std::vector< cpu_id > cpus)
Construct from a list of CPUs.
auto cpus() const noexcept -> std::vector< cpu_id > const &
Return the normalized sorted list of CPUs in the set.
thread_affinity(std::initializer_list< cpu_id > cpus)
Construct from an initializer list of CPUs.
thread_affinity()=default
Construct an empty affinity set (no CPU pinning requested).
auto contains(cpu_id cpu) const noexcept -> bool
Check whether a CPU is present in the affinity set.
void clear() noexcept
Remove all CPUs from the affinity set.
void add_cpu(cpu_id cpu)
Add a CPU to the affinity set.
auto empty() const noexcept -> bool
Return whether the affinity set is empty.
Strongly-typed CPU index used by affinity-related APIs.