Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
null_thread_backend.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
16#pragma once
17
18#include "thread_backend.h"
19
20namespace database
21{
22namespace integrated
23{
24namespace adapters
25{
26namespace backends
27{
28
37{
38public:
39 explicit null_thread_backend(const db_thread_config& /*config*/) {}
40 ~null_thread_backend() override = default;
41
43 {
44 return common::ok();
45 }
46
48 {
49 return common::ok();
50 }
51
52 bool is_initialized() const override
53 {
54 return true;
55 }
56
57 common::VoidResult execute(std::function<void()> task) override
58 {
59 // Execute synchronously on calling thread
60 if (task)
61 {
62 task();
63 }
64 return common::ok();
65 }
66
67 void wait_for_completion() override
68 {
69 // No-op: tasks already completed synchronously
70 }
71
72 bool wait_for_completion_timeout(std::chrono::milliseconds /*timeout*/) override
73 {
74 // No-op: tasks already completed
75 return true;
76 }
77
78 std::size_t worker_count() const override
79 {
80 return 0; // No worker threads
81 }
82
83 std::size_t queue_size() const override
84 {
85 return 0; // No queue
86 }
87
88 bool is_idle() const override
89 {
90 return true; // Always idle
91 }
92};
93
94} // namespace backends
95} // namespace adapters
96} // namespace integrated
97} // namespace database
std::size_t queue_size() const override
Get current queue size.
std::size_t worker_count() const override
Get number of worker threads.
bool wait_for_completion_timeout(std::chrono::milliseconds) override
Wait for completion with timeout.
bool is_idle() const override
Check if thread pool is idle.
common::VoidResult initialize() override
Initialize the thread backend.
common::VoidResult execute(std::function< void()> task) override
Execute a task (fire-and-forget)
bool is_initialized() const override
Check if backend is initialized.
void wait_for_completion() override
Wait for all pending tasks to complete.
common::VoidResult shutdown() override
Shutdown the thread backend gracefully.
Abstract base class for thread pool backends.
VoidResult ok()
Thread pool configuration for async operations.
Abstract interface for thread pool backends.