8#ifndef NUMAPP_CPUMASK_HPP_
9#define NUMAPP_CPUMASK_HPP_
11#include <system_error>
13#include <system_error>
30 using Bitmask<
Cpumask>::Bitmask;
48 return MakeFromString(cpustring, numa_parse_cpustring_all);
64 return MakeFromString(cpustring, numa_parse_cpustring);
68 using ParseFunc =
struct bitmask* (*)(
const char*);
69 [[nodiscard]]
static Cpumask MakeFromString(
char const* cpustring, ParseFunc func) {
71 auto* mask_ptr = func(cpustring);
72 if (mask_ptr ==
nullptr) {
73 throw std::system_error(std::make_error_code(std::errc::invalid_argument),
74 "Could not parse cpustring");
79 friend class Bitmask<Cpumask>;
81 return NumaBitmaskPtr(numa_allocate_cpumask(), &numa_free_cpumask);
96inline 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.