格式:函数 + 头文件 + 用例 + 解释说明

 

1.

函数

std::thread::hardware_concurrency()

头文件

#include <thread>

用例

unsigned long const hardware_threads = std::thread::hardware_concurrency();

说明

在新版C++标准库中是一个很有用的函数。这个函数会返回能并发在一个程序中的线程数量。例如,多核系统中,返回值可以是CPU核芯的数量。返回值也仅仅是一个提示,当系统信息无法获取时,函数也会返回0。但是,这也无法掩盖这个函数对启动线程数量的帮助。

 

相关文章:

  • 2021-09-20
  • 2023-01-08
  • 2022-03-11
猜你喜欢
  • 2021-11-21
  • 2021-08-15
  • 2022-01-01
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案