|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
High-performance asynchronous executor using thread_system. More...
#include <async_operations.h>

Public Member Functions | |
| async_executor (size_t thread_count=std::thread::hardware_concurrency(), const thread_context_type &=thread_context_type()) | |
| Constructs an async executor with specified thread count. | |
| ~async_executor () | |
| async_executor (const async_executor &)=delete | |
| async_executor & | operator= (const async_executor &)=delete |
| async_executor (async_executor &&)=delete | |
| async_executor & | operator= (async_executor &&)=delete |
| template<typename F , typename... Args> requires concepts::SubmittableTask<F, Args...> | |
| auto | submit (F &&func, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > > |
| Submits a task for asynchronous execution. | |
| void | shutdown () |
| Gracefully shuts down the executor. | |
| void | wait_for_completion () |
| Waits for all pending tasks to complete. | |
| size_t | pending_tasks () const |
| Returns the number of pending tasks. | |
| size_t | thread_count () const |
| Returns the number of worker threads. | |
| constexpr bool | is_using_thread_system () const |
| Checks if using thread_system implementation. | |
Private Member Functions | |
| void | worker_thread () |
Private Attributes | |
| std::vector< std::thread > | workers_ |
| std::queue< std::function< void()> > | tasks_ |
| std::mutex | queue_mutex_ |
| std::condition_variable | condition_ |
| std::atomic< bool > | stop_ |
| size_t | thread_count_ |
High-performance asynchronous executor using thread_system.
This executor leverages thread_system's advanced features when available:
When USE_THREAD_SYSTEM is not defined, falls back to std::thread implementation.
All methods are thread-safe and can be called from multiple threads.
Definition at line 328 of file async_operations.h.
|
inlineexplicit |
Constructs an async executor with specified thread count.
| thread_count | Number of worker threads (defaults to hardware concurrency) |
| context | Thread context for logging/monitoring (optional) |
Definition at line 362 of file async_operations.h.
References thread_count_, worker_thread(), and workers_.

|
inline |
Definition at line 375 of file async_operations.h.
References shutdown().

|
delete |
|
delete |
|
inlineconstexpr |
Checks if using thread_system implementation.
Definition at line 510 of file async_operations.h.
References database::async::using_thread_system.
Referenced by demonstrate_basic_usage(), and demonstrate_high_throughput().

|
delete |
|
delete |
|
inline |
Returns the number of pending tasks.
Definition at line 488 of file async_operations.h.
References queue_mutex_, and tasks_.
Referenced by demonstrate_shutdown().

|
inline |
Gracefully shuts down the executor.
Definition at line 441 of file async_operations.h.
References condition_, queue_mutex_, stop_, worker(), and workers_.
Referenced by demonstrate_shutdown(), TEST_F(), and ~async_executor().


|
inline |
Submits a task for asynchronous execution.
| F | Callable type - constrained by SubmittableTask concept |
| Args | Argument types |
| func | The callable to execute |
| args | Arguments to pass to the callable |
Definition at line 395 of file async_operations.h.
References condition_, queue_mutex_, stop_, and tasks_.
Referenced by compare_with_legacy(), demonstrate_basic_usage(), demonstrate_error_handling(), demonstrate_high_throughput(), and demonstrate_shutdown().

|
inline |
Returns the number of worker threads.
Definition at line 503 of file async_operations.h.
References thread_count_.
Referenced by demonstrate_basic_usage(), and TEST_F().

|
inline |
Waits for all pending tasks to complete.
Definition at line 465 of file async_operations.h.
References queue_mutex_, and tasks_.
Referenced by demonstrate_high_throughput().

|
inlineprivate |
Definition at line 519 of file async_operations.h.
References condition_, queue_mutex_, stop_, and tasks_.
Referenced by async_executor().

|
private |
Definition at line 548 of file async_operations.h.
Referenced by shutdown(), submit(), and worker_thread().
|
mutableprivate |
Definition at line 547 of file async_operations.h.
Referenced by pending_tasks(), shutdown(), submit(), wait_for_completion(), and worker_thread().
|
private |
Definition at line 549 of file async_operations.h.
Referenced by shutdown(), submit(), and worker_thread().
|
private |
Definition at line 546 of file async_operations.h.
Referenced by pending_tasks(), submit(), wait_for_completion(), and worker_thread().
|
private |
Definition at line 550 of file async_operations.h.
Referenced by async_executor(), and thread_count().
|
private |
Definition at line 545 of file async_operations.h.
Referenced by async_executor(), and shutdown().