std::thread..._concurrency(3)
π NAME π
okay so bestie, this is the C++ Standard Library page for std::thread::hardware_concurrency β and yes, the NAME line is literally std::thread::hardware_concurrency - std::thread::hardware_concurrency, because apparently weβre doing the whole βsay it twice, itβs iconicβ thing. The man page vibe is std::thread..._concurrency(3), iykyk. π
β¨ Synopsis β¨
static unsigned int hardware_concurrency() noexcept; (since C++11)
This cutie returns the number of concurrent threads supported by the implementation. The value should be considered only a hint β like, itβs giving βestimate,β not βsacred prophecy,β bestie. π¦
π«Ά Parameters π«Ά
(none) β literally no parameters. Zero. Zilch. Not a single argument to hand over. π
πΈ Return value πΈ
It returns the number of concurrent threads supported. And if the value is not well defined or not computable, it returns 0. Thatβs the whole return-value story, no cap. π
π₯ Example π₯
// Run this code
#include <iostream>
#include <thread>
int main()
{
unsigned int n = std::thread::hardware_concurrency();
std::cout << n << " concurrent threads are supported.\n";
}
Possible output:
4 concurrent threads are supported.
π See also π
hardware_destructive_interference_sizeβ min offset to avoid false sharing. Itβs tagged(C++17)(constant).hardware_constructive_interference_sizeβ max offset to promote true sharing. Also tagged(C++17)(constant).
mwah π β this little manpage moment came from cppreference.com, dated 2024.06.10. periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms