static unsigned int hardware_concurrency() noexcept;
|
(C++11 起) | |
返回实现所支持的并发线程数。值应当只考虑成提示。
目录 |
(无)
支持的并发线程数。若值不良好定义或不可计算,则返回 0 。
#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.
避免假共享的最小偏移 促使真共享的最大偏移 (常量) |