ThreadSchedule 4.1.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::worker_count Class Reference

Value type for pool worker count. More...

#include <worker_count.hpp>

Public Member Functions

 worker_count () noexcept=default
 Construct automatic worker count.
 worker_count (std::size_t value)
 Construct explicit worker count.
constexpr auto is_automatic () const noexcept -> bool
 Return whether this instance uses automatic resolution.
auto resolve () const noexcept -> std::size_t
 Resolve the effective worker count.

Static Public Member Functions

static constexpr auto automatic () noexcept -> worker_count
 Create automatic worker count.
static auto create (std::size_t value) noexcept -> result< worker_count >
 Create explicit worker count without exceptions.

Detailed Description

Value type for pool worker count.

The special automatic value resolves to at least one worker using std::thread::hardware_concurrency().

Definition at line 24 of file worker_count.hpp.

Constructor & Destructor Documentation

◆ worker_count() [1/2]

threadschedule::worker_count::worker_count ( )
defaultnoexcept

Construct automatic worker count.

Referenced by automatic(), create(), and worker_count().

◆ worker_count() [2/2]

threadschedule::worker_count::worker_count ( std::size_t value)
inlineexplicit

Construct explicit worker count.

Parameters
valueNumber of workers, must be > 0.
Exceptions
std::invalid_argumentif value is zero.

Definition at line 34 of file worker_count.hpp.

References worker_count().

Member Function Documentation

◆ automatic()

◆ create()

auto threadschedule::worker_count::create ( std::size_t value) ->result< worker_count >
inlinestaticnodiscardnoexcept

Create explicit worker count without exceptions.

Parameters
valueNumber of workers, must be > 0.
Returns
A valid worker_count or errc::invalid_argument.

Definition at line 52 of file worker_count.hpp.

References threadschedule::unexpected(), and worker_count().

◆ is_automatic()

auto threadschedule::worker_count::is_automatic ( ) const->bool
inlinenodiscardconstexprnoexcept

Return whether this instance uses automatic resolution.

Definition at line 61 of file worker_count.hpp.

Referenced by resolve().

◆ resolve()

auto threadschedule::worker_count::resolve ( ) const->std::size_t
inlinenodiscardnoexcept

Resolve the effective worker count.

Returns
Explicit value if set, otherwise max(1, hardware_concurrency).

Definition at line 71 of file worker_count.hpp.

References is_automatic().

Referenced by threadschedule::advanced::global_thread_pool::init(), and threadschedule::advanced::global_work_stealing_pool::init().


The documentation for this class was generated from the following file: