Use stdlib 'hardware_concurrency' to get logical processor count
This has the benifit of being multiplatform.
This commit is contained in:
parent
5d9a4b6830
commit
f17b80c61e
|
@ -12,6 +12,14 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace threading {
|
namespace threading {
|
||||||
|
|
||||||
|
uint32_t logical_processor_count() {
|
||||||
|
static uint32_t value = 0;
|
||||||
|
if (!value) {
|
||||||
|
value = std::thread::hardware_concurrency();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
thread_local uint32_t current_thread_id_ = UINT_MAX;
|
thread_local uint32_t current_thread_id_ = UINT_MAX;
|
||||||
|
|
||||||
uint32_t current_thread_id() {
|
uint32_t current_thread_id() {
|
||||||
|
|
|
@ -16,16 +16,6 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace threading {
|
namespace threading {
|
||||||
|
|
||||||
uint32_t logical_processor_count() {
|
|
||||||
static uint32_t value = 0;
|
|
||||||
if (!value) {
|
|
||||||
SYSTEM_INFO system_info;
|
|
||||||
GetSystemInfo(&system_info);
|
|
||||||
value = system_info.dwNumberOfProcessors;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnableAffinityConfiguration() {
|
void EnableAffinityConfiguration() {
|
||||||
HANDLE process_handle = GetCurrentProcess();
|
HANDLE process_handle = GetCurrentProcess();
|
||||||
DWORD_PTR process_affinity_mask;
|
DWORD_PTR process_affinity_mask;
|
||||||
|
|
Loading…
Reference in New Issue