MCPcopy Create free account
hub / github.com/Abc-Arbitrage/Disruptor-cpp / getThreadAffinity

Function getThreadAffinity

Disruptor/ThreadHelper_macOS.cpp:116–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114 }
115
116 AffinityMask getThreadAffinity()
117 {
118 AffinityMask mask;
119
120 cpu_set_t cpuSet;
121 CPU_ZERO(&cpuSet);
122 if (sched_getaffinity(0, sizeof(cpuSet), &cpuSet) == 0)
123 {
124 int processorCount = getProcessorCount();
125 int maskSize = (int) mask.size();
126 for (int i = 0; i < processorCount && i < maskSize; ++i)
127 {
128 if (CPU_ISSET(i, &cpuSet))
129 mask.set(i);
130 }
131 }
132
133 return mask;
134 }
135
136 uint32_t getCurrentThreadId()
137 {

Callers

nothing calls this directly

Calls 6

CPU_ZEROFunction · 0.85
sched_getaffinityFunction · 0.85
CPU_ISSETFunction · 0.85
getProcessorCountFunction · 0.70
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected