#pragma once #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include class CPU { public: typedef std::vector ThreadIdVec; typedef std::vector CPUVec; typedef std::unordered_map CPU2CoreMap; typedef std::unordered_map> Core2CPUsMap; public: static int count(); static int getaffinity(const pthread_t thread_id, cpu_set_t *cpuset); static int setaffinity(const pthread_t thread_id, cpu_set_t *cpuset); static int setaffinity(const pthread_t thread_id, const int cpu); static int setaffinity(const pthread_t thread_id, const std::set cpus); static CPU::CPUVec cpus(); static CPU::CPU2CoreMap cpu2core(); static CPU::Core2CPUsMap core2cpus(); };