27 using numaid_t = USHORT;
38 mutable std::mutex m_mutex;
39 std::map<numaid_t, numaentry_t> m_available;
42 static numaid_t numa_node()
45 PROCESSOR_NUMBER Processor;
46 GetCurrentProcessorNumberEx(&Processor);
47 USHORT NodeNumber = 0;
48 return GetNumaProcessorNodeEx(&Processor, &NodeNumber) ? NodeNumber : 0;
49#elif defined(__APPLE__)
52 return numa_node_of_cpu(sched_getcpu());
56 numaentry_t& numa_entry(numaid_t numa = numa_node())
58 const std::lock_guard<std::mutex> guard(m_mutex);
59 return m_available[numa];
70 T
pop(_In_ numaid_t numa = numa_node())
72 auto& ne = numa_entry(numa);
73 const std::lock_guard<spinlock> guard(ne.lock);
74 if (!ne.list.empty()) {
75 auto r = std::move(ne.list.front());
88 void push(_Inout_ T&& r, _In_ numaid_t numa = numa_node())
90 auto& ne = numa_entry(numa);
91 const std::lock_guard<spinlock> guard(ne.lock);
92 ne.list.push_front(std::move(r));
100 const std::lock_guard<std::mutex> guard_m(m_mutex);
101 for (
auto& ne : m_available) {
102 const std::lock_guard<spinlock> guard_l(ne.second.lock);
103 while (!ne.second.list.empty())
104 ne.second.list.pop_front();