std::jthread::hardware_concurrency
來自 cppreference.com
static unsigned int hardware_concurrency() noexcept; |
(C++20 起) | |
返回實現支援的併發執行緒數。該值僅應被視為一個提示。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
支援的併發執行緒數。如果該值未明確定義或無法計算,則返回 0。
[編輯] 示例
執行此程式碼
#include <iostream> #include <thread> int main() { unsigned int n = std::jthread::hardware_concurrency(); std::cout << n << " concurrent threads are supported.\n"; }
可能的輸出
4 concurrent threads are supported.
[編輯] 參閱
避免偽共享的最小偏移量 促進真共享的最大偏移量 (常量) |