Namespaces
Variants
Views
Actions

std::thread::hardware_concurrency

From cppreference.com
< cpp‎ | thread‎ | thread
Revision as of 20:40, 8 February 2013 by Cubbi (Talk | contribs)

static unsigned hardware_concurrency();
(since C++11)

Returns number of concurrent threads supported by the implementation. The value should be considered only a hint.

Contents

Parameters

(none)

Return value

number of concurrent threads supported. If the value is not well defined or not computable, returns 0.

Exceptions

noexcept specification:  
noexcept
  

Example

#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.