ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
detail/pool/worker_count.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cstddef>
5#include <stdexcept>
6#include <thread>
7
9{
10
11[[nodiscard]] inline auto
12default_worker_count() noexcept -> std::size_t
13{
14 return (std::max)(std::size_t{ 1 }, static_cast<std::size_t>(std::thread::hardware_concurrency()));
15}
16
17[[nodiscard]] inline auto
18checked_worker_count(std::size_t count) -> std::size_t
19{
20 if (count == 0)
21 throw std::invalid_argument("worker count must be positive");
22 return count;
23}
24
25} // namespace threadschedule::detail
Aggregates multiple thread_registry_backend instances into a single queryable view.
auto default_worker_count() noexcept -> std::size_t
auto checked_worker_count(std::size_t count) -> std::size_t