24#include <condition_variable>
Simple thread pool using std::thread.
common::VoidResult execute(std::function< void()> task) override
Execute a task (fire-and-forget)
std::size_t queue_size() const override
Get current queue size.
~fallback_thread_backend() override
fallback_thread_backend & operator=(const fallback_thread_backend &)=delete
std::atomic< bool > shutdown_requested_
std::size_t worker_count() const override
Get number of worker threads.
fallback_thread_backend(fallback_thread_backend &&)=delete
bool is_initialized() const override
Check if backend is initialized.
fallback_thread_backend & operator=(fallback_thread_backend &&)=delete
void worker_thread()
Worker thread function.
bool is_idle() const override
Check if thread pool is idle.
common::VoidResult initialize() override
Initialize the thread backend.
std::condition_variable completion_cv_
const db_thread_config & config_
common::VoidResult shutdown() override
Shutdown the thread backend gracefully.
std::mutex completion_mutex_
std::atomic< std::size_t > active_tasks_
std::condition_variable queue_cv_
fallback_thread_backend(const fallback_thread_backend &)=delete
std::vector< std::thread > workers_
fallback_thread_backend(const db_thread_config &config)
bool wait_for_completion_timeout(std::chrono::milliseconds timeout) override
Wait for completion with timeout.
void wait_for_completion() override
Wait for all pending tasks to complete.
std::queue< std::function< void()> > task_queue_
Abstract base class for thread pool backends.
Thread pool configuration for async operations.
Abstract interface for thread pool backends.