std::thread::hardware_concurrency

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.

参阅

避免假共享的最小偏移
促使真共享的最大偏移
(常量)

版本历史

  • (当前 | 先前 2017年8月25日 (五) 04:50Fruderica讨论 | 贡献. . (773字节) (-353). . (撤销)
  • 当前 | 先前 2012年11月2日 (五) 18:30P12bot讨论 | 贡献 . . (1,126字节) (+369). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 03:32P12讨论 | 贡献 . . (757字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (757字节) (+757). . (Translated from the English version using Google Translate)