10#ifndef NUMAPP_CPUMASK_HPP_
11#define NUMAPP_CPUMASK_HPP_
13#include <system_error>
15#include <system_error>
32 using Bitmask<
Cpumask>::Bitmask;
50 return MakeFromString(cpustring, numa_parse_cpustring_all);
66 return MakeFromString(cpustring, numa_parse_cpustring);
70 using ParseFunc =
struct bitmask* (*)(
const char*);
71 [[nodiscard]]
static Cpumask MakeFromString(
char const* cpustring, ParseFunc func) {
73 auto* mask_ptr = func(cpustring);
74 if (mask_ptr ==
nullptr) {
75 throw std::system_error(std::make_error_code(std::errc::invalid_argument),
76 "Could not parse cpustring");
81 friend class Bitmask<Cpumask>;
83 return NumaBitmaskPtr(numa_allocate_cpumask(), &numa_free_cpumask);
98inline std::ostream& operator<<(std::ostream& os,
Cpumask const& mask) {
Contains declarations for numapp::Bitmask.
static Cpumask MakeFromCpuString(char const *cpustring)
Construct Cpumask from cpustring that considers current cpuset.
static Cpumask MakeFromCpuStringAll(char const *cpustring)
Construct Cpumask from cpustring that does not consider current cpuset.
std::unique_ptr< struct bitmask, void(*)(struct bitmask *)> NumaBitmaskPtr
Lowlevel bitmask type.
std::ostream & FormatBitmask(std::ostream &os, bitmask const *mask, int min_bits)
Formats mask and inserts it to os.