169 template <typename F, typename... Args>
170 requires concepts::SubmittableTask<F, Args...>
171 auto
submit(F&& f, Args&&... args) -> std::future<std::invoke_result_t<F, Args...>>;
218 std::unique_ptr<backends::thread_backend>
backend_;
225template <typename F, typename... Args>
226 requires concepts::SubmittableTask<F, Args...>
229 using return_type = std::invoke_result_t<F, Args...>;
231 auto task = std::make_shared<std::packaged_task<return_type()>>(
232 std::bind(std::forward<F>(f), std::forward<Args>(args)...));
234 auto result = task->get_future();
236 execute([task = std::move(task)]() { (*task)(); });
Thread pool adapter for async database operations.
auto submit(F &&f, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > >
Submit a task and get a future.
common::VoidResult shutdown()
Shutdown thread pool gracefully.
bool wait_for_completion_timeout(std::chrono::milliseconds timeout)
Wait for tasks with timeout.
common::VoidResult initialize()
Initialize thread pool.
thread_adapter(const thread_adapter &)=delete
void wait_for_completion()
Wait for all pending tasks to complete.
std::unique_ptr< backends::thread_backend > backend_
Thread backend implementation.
~thread_adapter()
Destructor - ensures graceful shutdown.
std::size_t queue_size() const
Get current queue size.
thread_adapter(const db_thread_config &config, thread_backend_type backend_type=thread_backend_type::auto_select)
Construct thread adapter with configuration.
std::size_t worker_count() const
Get number of worker threads.
bool is_initialized() const
Check if thread pool is initialized.
common::VoidResult execute(std::function< void()> task)
Execute a task (fire-and-forget)
const db_thread_config & config_
static std::unique_ptr< backends::thread_backend > create_backend(const db_thread_config &config, thread_backend_type backend_type)
Create appropriate backend based on type.
thread_adapter & operator=(const thread_adapter &)=delete
bool is_idle() const
Check if thread pool is idle.
thread_adapter(thread_adapter &&) noexcept
Common Result<T> pattern for integrated database system.
C++20 concepts for database_system type validation.
Unified configuration for integrated database system.
thread_backend_type
Thread backend type selection.
@ auto_select
Automatically select best available backend.
@ null
No-op backend (discard all logs)
@ auto_select
Automatically select best available backend.
@ fallback
Use std::cout + std::ofstream.
backend_type
Database backend type enumeration.
kcenon::common::VoidResult VoidResult
Primary VoidResult type - use this for void operations.
Thread pool configuration for async operations.