std::thread::hardware_concurrency
线程::硬件[医]并发性
static unsigned hardware_concurrency( | | (since C++11) |
---|
返回实现支持的并发线程数。该值只应视为提示。
参数
%280%29
返回值
支持的并发线程数。如果该值未定义好或不可计算,则返回0
...
例外
noexcept
规格:
noexcept
例
二次
#include <iostream>
#include <thread>
int main() {
unsigned int n = std::thread::hardware_concurrency(
std::cout << n << " concurrent threads are supported.\n";
}
二次
可能的产出:
二次
4 concurrent threads are supported.
二次
另见
hardware_destructive_interference_sizehardware_constructive_interference_size (C++17) | min offset to avoid false sharingmax offset to promote true sharing (constant) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。