Stroika Library 3.0d24
 
Loading...
Searching...
No Matches
CPUAffinity.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ******************* Execution::SetCPUAffinityQuietly ***************************
10 ********************************************************************************
11 */
12 inline bool SetCPUAffinityQuietly (const LogicalCPUCoreSet& cores) noexcept
13 {
14 // The if constexpr matters: where affinity is unsupported this compiles to 'return false', so a
15 // caller on macOS pays nothing - not even a try/catch frame - for asking.
16 if constexpr (kCPUAffinitySupported) {
17 try {
18 SetCPUAffinity (cores);
19 return true;
20 }
21 catch (...) {
22 return false;
23 }
24 }
25 else {
26 return false;
27 }
28 }
29
30}
Set<T> is a container of T, where once an item is added, additionally adds () do nothing.
constexpr bool kCPUAffinitySupported
Can CPU affinity be controlled on this platform at all?
Definition CPUAffinity.h:89
void SetCPUAffinity(const LogicalCPUCoreSet &cores)
Restrict this process to the given logical CPU cores.
bool SetCPUAffinityQuietly(const LogicalCPUCoreSet &cores) noexcept
Like SetCPUAffinity (), but returns false rather than throwing.