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

Function getThreadAffinity

Disruptor/ThreadHelper_Linux.cpp:46–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 AffinityMask getThreadAffinity()
47 {
48 AffinityMask mask;
49
50 cpu_set_t cpuSet;
51 CPU_ZERO(&cpuSet);
52 if (pthread_getaffinity_np(pthread_self(), sizeof(cpuSet), &cpuSet) == 0)
53 {
54 int processorCount = getProcessorCount();
55 int maskSize = (int) mask.size();
56 for (int i = 0; i < processorCount && i < maskSize; ++i)
57 {
58 if (CPU_ISSET(i, &cpuSet))
59 mask.set(i);
60 }
61 }
62
63 return mask;
64 }
65
66 uint32_t getCurrentThreadId()
67 {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected