carb::this_thread::setAffinity
Defined in carb/thread/Util.h
-
inline bool carb::this_thread::setAffinity(const thread::CpuMaskVector &masks)
Sets the CPU Affinity for the current thread.
On Windows each entry in the CpuMaskVector represents a Processor Group. Each thread can only belong to a single Processor Group, so this function will only set the CPU Affinity to the first non-zero entry in the provided CpuMaskVector. That is to say, if both
masks
[0] andmasks
[1] have bits sets, only the CPUs inmasks
[0] will be set for the affinity.On Linux, the CpuMaskVector is analogous to a cpu_set_t. There are no restrictions on the number of CPUs that the affinity mask can contain.
- Parameters
masks – Affinity masks to set.
- Returns
True if the function succeeded, false otherwise. If
masks
is empty, or has no bits set, false will be returned. If the underlying function for setting affinity failed, thenerrno
orlast-error
will be set.