|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
Demonstrates multi-threaded database usage with independent database_manager instances. More...
#include <iostream>#include <memory>#include <string>#include <thread>#include <vector>#include <mutex>#include <variant>#include "database/database_manager.h"#include "database/core/database_context.h"
Go to the source code of this file.
Functions | |
| static void | thread_print (int thread_id, const std::string &msg) |
| Thread-safe print helper. | |
| static void | worker (int thread_id, const std::string &connection_string) |
| Worker function: creates its own connection, inserts data, reads it back, and disconnects. | |
| int | main () |
Variables | |
| static std::mutex | cout_mutex |
Demonstrates multi-threaded database usage with independent database_manager instances.
This example shows how to:
Design note: database_manager instances are not thread-safe for concurrent operations on the same instance. Each thread should use its own database_manager. The underlying connection pooling is handled server-side (ProxyMode) or by creating separate connections.
Prerequisites:
Definition in file connection_pool_demo.cpp.
| int main | ( | ) |
Definition at line 98 of file connection_pool_demo.cpp.
References worker().

|
static |
Thread-safe print helper.
Definition at line 44 of file connection_pool_demo.cpp.
References cout_mutex.
Referenced by worker().

|
static |
Worker function: creates its own connection, inserts data, reads it back, and disconnects.
Definition at line 54 of file connection_pool_demo.cpp.
References thread_print().
Referenced by main(), database::async::async_executor::shutdown(), and database::integrated::adapters::backends::fallback_thread_backend::shutdown().


|
static |
Definition at line 39 of file connection_pool_demo.cpp.
Referenced by thread_print().