File tree Expand file tree Collapse file tree 4 files changed +46
-4
lines changed
Expand file tree Collapse file tree 4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2019-2025 Diligent Graphics LLC
2+ * Copyright 2019-2026 Diligent Graphics LLC
33 * Copyright 2015-2019 Egor Yusov
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,6 +111,13 @@ struct BasicPlatformMisc
111111 // / Sets the current thread affinity mask and on success returns the previous mask.
112112 static Uint64 SetCurrentThreadAffinity (Uint64 Mask);
113113
114+ // / Sets the current process affinity mask.
115+ // / On success, returns true. On failure, returns false and the affinity mask is not changed.
116+ static Bool SetProcessAffinity (Uint64 Mask);
117+
118+ // / Returns the current process affinity mask. On failure, returns 0.
119+ static Uint64 GetProcessAffinity ();
120+
114121 // / Sets the name of the current thread.
115122 static void SetCurrentThreadName (const char * Name);
116123
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2019-2025 Diligent Graphics LLC
2+ * Copyright 2019-2026 Diligent Graphics LLC
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -48,6 +48,18 @@ Uint64 BasicPlatformMisc::SetCurrentThreadAffinity(Uint64 Mask)
4848 return 0 ;
4949}
5050
51+ Bool BasicPlatformMisc::SetProcessAffinity (Uint64 Mask)
52+ {
53+ LOG_WARNING_MESSAGE_ONCE (" SetProcessAffinity is not implemented on this platform." );
54+ return false ;
55+ }
56+
57+ Uint64 BasicPlatformMisc::GetProcessAffinity ()
58+ {
59+ LOG_WARNING_MESSAGE_ONCE (" GetProcessAffinity is not implemented on this platform." );
60+ return 0 ;
61+ }
62+
5163void BasicPlatformMisc::SetCurrentThreadName (const char * Name)
5264{
5365 LOG_WARNING_MESSAGE_ONCE (" SetCurrentThreadName is not implemented on this platform." );
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2019-2025 Diligent Graphics LLC
2+ * Copyright 2019-2026 Diligent Graphics LLC
33 * Copyright 2015-2019 Egor Yusov
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -168,6 +168,13 @@ struct WindowsMisc : public BasicPlatformMisc
168168 // / On failure, returns 0.
169169 static Uint64 SetCurrentThreadAffinity (Uint64 Mask);
170170
171+ // / Sets the current process affinity mask.
172+ // / On success, returns true. On failure, returns false and the affinity mask is not changed.
173+ static Bool SetProcessAffinity (Uint64 Mask);
174+
175+ // / Returns the process affinity mask. On failure, returns 0.
176+ static Uint64 GetProcessAffinity ();
177+
171178 static ThreadPriority GetCurrentThreadPriority ();
172179
173180 // / Sets the current thread priority and on success returns the previous priority.
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2019-2025 Diligent Graphics LLC
2+ * Copyright 2019-2026 Diligent Graphics LLC
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -43,6 +43,22 @@ Uint64 WindowsMisc::SetCurrentThreadAffinity(Uint64 Mask)
4343 return SetThreadAffinityMask (hCurrThread, static_cast <DWORD_PTR>(Mask));
4444}
4545
46+ Bool WindowsMisc::SetProcessAffinity (Uint64 Mask)
47+ {
48+ const HANDLE hCurrProcess = GetCurrentProcess ();
49+ return SetProcessAffinityMask (hCurrProcess, static_cast <DWORD_PTR>(Mask)) != 0 ;
50+ }
51+
52+ Uint64 WindowsMisc::GetProcessAffinity ()
53+ {
54+ DWORD_PTR ProcessAffinityMask = 0 ;
55+ DWORD_PTR SystemAffinityMask = 0 ;
56+ const HANDLE hCurrProcess = GetCurrentProcess ();
57+ if (GetProcessAffinityMask (hCurrProcess, &ProcessAffinityMask, &SystemAffinityMask))
58+ return static_cast <Uint64>(ProcessAffinityMask);
59+ else
60+ return 0 ;
61+ }
4662
4763static ThreadPriority WndPriorityToThreadPiority (int priority)
4864{
You can’t perform that action at this time.
0 commit comments