|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Observers | ||||
jthread::hardware_concurrency | ||||
| Operations | ||||
| Stop token handling | ||||
| Non-member functions | ||||
staticunsignedint hardware_concurrency()noexcept; | (since C++20) | |
Returns the number of concurrent threads supported by the implementation. The value should be considered only a hint.
Contents |
(none)
Number of concurrent threads supported. If the value is not well defined or not computable, returns0.
#include <iostream>#include <thread> int main(){unsignedint n= std::jthread::hardware_concurrency();std::cout<< n<<" concurrent threads are supported.\n";}
Possible output:
4 concurrent threads are supported.
| min offset to avoid false sharing max offset to promote true sharing (constant)[edit] |