| 754 | } |
| 755 | |
| 756 | void restore_thread_affinity(const ThreadAffinity& previous) { |
| 757 | if (!previous.valid) return; |
| 758 | #if defined(_WIN32) |
| 759 | // Clearing an originally empty selection restores process-default/all-group eligibility without |
| 760 | // turning the caller's implicit Windows 11 affinity into an explicit single-group hard mask. |
| 761 | if (!SetThreadSelectedCpuSets(GetCurrentThread(), previous.cpu_sets.empty() ? nullptr : previous.cpu_sets.data(), |
| 762 | (ULONG) previous.cpu_sets.size())) |
| 763 | std::fprintf(stderr, "strata cpu pool: host CPU Set restoration failed: %lu\n", |
| 764 | (unsigned long) GetLastError()); |
| 765 | #else |
| 766 | const int error = detail::set_thread_affinity(previous.mask); |
| 767 | if (error != 0) |
| 768 | std::fprintf(stderr, "strata cpu pool: host affinity restoration failed: %d\n", error); |
| 769 | #endif |
| 770 | } |
| 771 | |
| 772 | namespace { |
| 773 | std::atomic<const ExpertPool*> g_diag_pool{nullptr}; |