A CPU set for use with sched_setaffinity(2) or pthread_setaffinity_np(3).
More...
#include <xentara/utils/linux/CpuSet.hpp>
|
constexpr | CpuSet ()=default |
| Default constructor.
|
|
auto | capacity () -> int |
| Gets the capacity of the set.
|
|
auto | reserve (int maximumCpuIndex) -> void |
| Reserve space for a certain number of CPUs.
|
|
auto | add (int cpuIndex) -> void |
| Adds a CPU.
|
|
auto | remove (int cpuIndex) -> void |
| Removes a CPU.
|
|
auto | clear () -> void |
| Removes all CPUs.
|
|
auto | count () const -> int |
| Counts the number of CPUs added to the set.
|
|
| operator const cpu_set_t * () const noexcept |
| Conversion to a cpu_set_t pointer.
|
|
| operator cpu_set_t * () noexcept |
| Conversion to a cpu_set_t pointer.
|
|
auto | data () const noexcept -> const cpu_set_t * |
| Gets the data.
|
|
auto | data () noexcept -> cpu_set_t * |
| Gets the data.
|
|
auto | dataSize () const noexcept -> std::size_t |
| Get the size of the data in bytes.
|
|
A CPU set for use with sched_setaffinity(2) or pthread_setaffinity_np(3).
- Note
- This class is only available under Linux
◆ CpuSet()
constexpr xentara::utils::linux::CpuSet::CpuSet |
( |
| ) |
|
|
constexprdefault |
◆ add()
auto xentara::utils::linux::CpuSet::add |
( |
int |
cpuIndex | ) |
-> void |
Adds a CPU.
- Parameters
-
cpuIndex | The 0-based index of the CPU to add. The CPU set is automatically expanded to be able to hold the given CPU index, if necessary. The CPU index must not be less than 0. |
◆ capacity()
auto xentara::utils::linux::CpuSet::capacity |
( |
| ) |
-> int |
Gets the capacity of the set.
- Returns
- The maximum CPU index that can be added without a reallocation taking place.
◆ clear()
auto xentara::utils::linux::CpuSet::clear |
( |
| ) |
-> void |
◆ count()
auto xentara::utils::linux::CpuSet::count |
( |
| ) |
const -> int |
Counts the number of CPUs added to the set.
◆ data() [1/2]
auto xentara::utils::linux::CpuSet::data |
( |
| ) |
const -> const cpu_set_t *
|
|
noexcept |
◆ data() [2/2]
auto xentara::utils::linux::CpuSet::data |
( |
| ) |
-> cpu_set_t *
|
|
noexcept |
◆ dataSize()
auto xentara::utils::linux::CpuSet::dataSize |
( |
| ) |
const -> std::size_t |
|
noexcept |
◆ operator const cpu_set_t *()
xentara::utils::linux::CpuSet::operator const cpu_set_t * |
( |
| ) |
const |
|
noexcept |
Conversion to a cpu_set_t pointer.
◆ operator cpu_set_t *()
xentara::utils::linux::CpuSet::operator cpu_set_t * |
( |
| ) |
|
|
noexcept |
Conversion to a cpu_set_t pointer.
◆ remove()
auto xentara::utils::linux::CpuSet::remove |
( |
int |
cpuIndex | ) |
-> void |
Removes a CPU.
- Parameters
-
cpuIndex | The 0-based index of the CPU to add. It is safe to specify a CPU index that is greater than the current capacity. The CPU index must not be less than 0. |
◆ reserve()
auto xentara::utils::linux::CpuSet::reserve |
( |
int |
maximumCpuIndex | ) |
-> void |
Reserve space for a certain number of CPUs.
The CPU set is expanded if necessary. The set is never made smaller, however. Due to the way the kernel stores CPU sets, the actual resulting capacity can be larger that the value specified.
- Parameters
-
maximumCpuIndex | The maximum CPU index that can be added without a reallocation taking place. must not be less than 0. |
◆ _longData
cpu_set_t* xentara::utils::linux::CpuSet::_longData |
◆ _shortData
cpu_set_t xentara::utils::linux::CpuSet::_shortData |