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

Function pthread_setaffinity_np

Disruptor/ThreadHelper_macOS.cpp:70–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 }
69
70 int pthread_setaffinity_np(pthread_t thread, size_t cpu_size,
71 cpu_set_t *cpu_set)
72 {
73 thread_port_t mach_thread;
74 int core = 0;
75
76 for (core = 0; core < 8 * (int)cpu_size; core++) {
77 if (CPU_ISSET(core, cpu_set)) break;
78 }
79
80 thread_affinity_policy_data_t policy = { core };
81 mach_thread = pthread_mach_thread_np(thread);
82 thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY,
83 (thread_policy_t)&policy, 1);
84 return 0;
85 }
86
87
88 size_t getProcessorCount()

Callers 2

setThreadAffinityFunction · 0.85
setThreadAffinityFunction · 0.85

Calls 1

CPU_ISSETFunction · 0.85

Tested by

no test coverage detected