std::jthread:: hardware_concurrency
From cppreference.net
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::jthread
| Member functions | ||||
| Observers | ||||
|
jthread::hardware_concurrency
|
||||
| Operations | ||||
| Stop token handling | ||||
| Non-member functions | ||||
|
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.
関連項目
|
偽共有を回避するための最小オフセット
真の共有を促進するための最大オフセット (定数) |