Spec-Zone.ru › C++

std::jthread::hardware_concurrency

static unsigned int hardware_concurrency() noexcept;
(since C++20)

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

Parameters

(none)

Return value

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

Example

#include <iostream>
#include <thread>

int main()
{
    unsigned int n = std::jthread::hardware_concurrency();
    std::cout << n << " concurrent threads are supported.\n";
}

Possible output:

4 concurrent threads are supported.

See also

hardware_destructive_interference_sizehardware_constructive_interference_size
(C++17)
min offset to avoid false sharing
max offset to promote true sharing
(constant)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/thread/jthread/hardware_concurrency

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API