Files
Xenia-Canary/src/xenia/base/threading.cc
sephiroth99 f17b80c61e Use stdlib 'hardware_concurrency' to get logical processor count
This has the benifit of being multiplatform.
2016-01-20 11:04:28 -05:00

34 lines
1.0 KiB
C++

/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/base/threading.h"
namespace xe {
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;
uint32_t current_thread_id() {
return current_thread_id_ == UINT_MAX ? current_thread_system_id()
: current_thread_id_;
}
void set_current_thread_id(uint32_t id) { current_thread_id_ = id; }
} // namespace threading
} // namespace xe