thread_pool

namespace opentl::thdpl {
    template <typename T>
    class thread_pool;

    template <typename R, typename... Args>
    class thread_pool<R(Args...)>;
}

Thread pool for queueing tasks.

Template Parameters

Name Description
R The function return type.
Args The function argument types.

Member Types

Type Description
job_type The job type, thread_job<R(Args...)>.

Member Functions

Name Return Type Description
~thread_pool()   Destructs a thread_pool, stopping it and joining its threads.
has_jobs() bool Checks if there are any pending jobs.
is_running() bool Checks if the thread pool is running.
queue_job(F&&, Args&&...) std::future<R> Queues a new job on the thread pool.
default_num_threads() std::size_t Returns the default number of threads for the pool.
start(std::size_t) void Starts the thread pool.
stop() void Stops the thread pool, running any queued jobs before joining.