15#include "forward_declarations.h"
31 template<detail::JobType job_type = job_types>
115 [[nodiscard]] std::shared_ptr<typed_thread_pool_t<job_type>>
build() {
117 throw std::invalid_argument(
"Invalid thread pool configuration");
120 auto pool = std::make_shared<typed_thread_pool_t<job_type>>(
title_);
124 auto worker = std::make_unique<typed_thread_worker_t<job_type>>(
127 pool->enqueue(std::move(worker));
131 auto result = pool->start();
133 throw std::runtime_error(
"Failed to start thread pool: " +
146 title_ =
"typed_thread_pool";
156 std::string
title_ =
"typed_thread_pool";
168 template<detail::JobType job_type = job_types>
const std::string & message() const noexcept
Gets the error message.
A template class representing either a value or an error.
error & get_error() &
Gets the error.
Typed thread pool builder template.
bool validate() const
Validate the current configuration.
typed_thread_pool_builder()=default
Construct a new builder with default settings.
typed_thread_pool_builder & with_time_tagging(bool enable)
Enable or disable time tagging for workers.
std::vector< job_type > job_types_
typed_thread_pool_builder & with_auto_start(bool auto_start)
Enable or disable automatic pool startup.
typed_thread_pool_builder & reset()
Reset the builder to default values.
typed_thread_pool_builder & with_worker_count(size_t count)
Set the number of worker threads.
typed_thread_pool_builder & with_title(const std::string &title)
Set the title/name for the thread pool.
typed_thread_pool_builder & with_job_types(const std::vector< job_type > &types)
Set the job types that workers should handle.
typed_thread_pool_builder & with_queue_size(size_t size)
Set the queue size for the thread pool.
std::shared_ptr< typed_thread_pool_t< job_type > > build()
Build the typed thread pool with current configuration.
Central configuration for typed_thread_pool module.
Job type definitions for the typed thread pool.
constexpr size_t default_queue_size
constexpr size_t max_workers
constexpr size_t min_workers
constexpr size_t default_worker_count
Core threading foundation of the thread system library.
typed_thread_pool_builder< job_type > create_pool_builder()
Convenience function to create a builder.