static_thread_pool in Coroutine Library
Understand the use of static_thread_pool in C++23 with an example.
We'll cover the following
You can combine when_all
with thread pools in cppcoro.
static_thread_pool
static_thread_pool
schedules work on a fixed-size pool of threads.
cppcoro::static_thread_pool
can be invoked with and without a number. The number stands for the number of threads that are created. If you don’t specify a number, the C++11 function std::thread::hardware_concurrency()
is used. std::thread::hardware_concurrency gives you a hint for the number of hardware threads supported by your system. This may be the number of processors or cores you have.
Let me try it out. The following example is based on the previous one using the awaitable when_any
. This time, the coroutines are executed concurrently.
Get hands-on with 1400+ tech skills courses.