|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Bridge for thread pool integration implementing INetworkBridge. More...
#include <thread_pool_bridge.h>


Public Types | |
| enum class | BackendType { ThreadSystem , CommonSystem , Custom } |
| Type of thread pool backend. More... | |
Public Member Functions | |
| ThreadPoolBridge (std::shared_ptr< thread_pool_interface > pool, BackendType backend_type=BackendType::Custom) | |
| Construct bridge with custom thread pool. | |
| ~ThreadPoolBridge () override | |
| Destructor. | |
| VoidResult | initialize (const BridgeConfig &config) override |
| Initialize the bridge with configuration. | |
| VoidResult | shutdown () override |
| Shutdown the bridge. | |
| bool | is_initialized () const override |
| Check if the bridge is initialized. | |
| BridgeMetrics | get_metrics () const override |
| Get current metrics. | |
| std::shared_ptr< thread_pool_interface > | get_thread_pool () const |
| Get the underlying thread pool. | |
| BackendType | get_backend_type () const |
| Get the backend type. | |
Public Member Functions inherited from kcenon::network::integration::INetworkBridge | |
| virtual | ~INetworkBridge ()=default |
Static Public Member Functions | |
| static std::shared_ptr< ThreadPoolBridge > | from_thread_system (const std::string &pool_name="network_pool") |
| Create bridge from thread_system. | |
Private Attributes | |
| std::shared_ptr< thread_pool_interface > | pool_ |
| BackendType | backend_type_ |
| std::atomic< bool > | initialized_ {false} |
| std::mutex | metrics_mutex_ |
| BridgeMetrics | cached_metrics_ |
Bridge for thread pool integration implementing INetworkBridge.
This class consolidates thread_system and common_system thread pool integrations into a single, unified bridge. It provides factory methods for creating bridges from different backend types.
Backend Types:
Lifecycle:
Thread Safety:
Definition at line 81 of file thread_pool_bridge.h.
|
strong |
Type of thread pool backend.
| Enumerator | |
|---|---|
| ThreadSystem | Uses thread_system's thread pool. |
| CommonSystem | Uses common_system's IExecutor. |
| Custom | Uses custom thread_pool_interface. |
Definition at line 87 of file thread_pool_bridge.h.
|
explicit |
Construct bridge with custom thread pool.
| pool | Thread pool implementation |
| backend_type | Type of backend (default: Custom) |
| std::invalid_argument | if pool is nullptr |
Example:
Definition at line 15 of file thread_pool_bridge.cpp.
References pool_.
|
override |
Destructor.
Automatically calls shutdown() if initialized
Definition at line 24 of file thread_pool_bridge.cpp.
References initialized_, and shutdown().

|
static |
Create bridge from thread_system.
| pool_name | Thread pool name (default: "network_pool") |
Creates a bridge using thread_system's thread pool via thread_integration_manager.
Example:
Definition at line 125 of file thread_pool_bridge.cpp.
References kcenon::network::integration::thread_integration_manager::get_thread_pool(), kcenon::network::integration::thread_integration_manager::instance(), and ThreadSystem.
Referenced by kcenon::network::integration::NetworkSystemBridge::create_default(), and kcenon::network::integration::NetworkSystemBridge::with_thread_system().


| ThreadPoolBridge::BackendType kcenon::network::integration::ThreadPoolBridge::get_backend_type | ( | ) | const |
Get the backend type.
Definition at line 121 of file thread_pool_bridge.cpp.
References backend_type_.
|
overridevirtual |
Get current metrics.
Custom Metrics:
Thread Safety: Safe to call concurrently
Implements kcenon::network::integration::INetworkBridge.
Definition at line 93 of file thread_pool_bridge.cpp.
References backend_type_, cached_metrics_, kcenon::network::integration::BridgeMetrics::custom_metrics, initialized_, kcenon::network::integration::BridgeMetrics::is_healthy, kcenon::network::integration::BridgeMetrics::last_activity, metrics_mutex_, and pool_.
| std::shared_ptr< thread_pool_interface > kcenon::network::integration::ThreadPoolBridge::get_thread_pool | ( | ) | const |
Get the underlying thread pool.
Thread Safety: Safe to call after initialization
Example:
Definition at line 117 of file thread_pool_bridge.cpp.
References pool_.
|
overridevirtual |
Initialize the bridge with configuration.
| config | Configuration parameters |
Configuration Properties:
Error Conditions:
Example:
Implements kcenon::network::integration::INetworkBridge.
Definition at line 30 of file thread_pool_bridge.cpp.
References kcenon::network::error_codes::common_errors::already_exists, backend_type_, cached_metrics_, config, kcenon::network::integration::BridgeMetrics::custom_metrics, kcenon::network::error_void(), initialized_, kcenon::network::error_codes::common_errors::invalid_argument, kcenon::network::integration::BridgeMetrics::is_healthy, kcenon::network::integration::BridgeMetrics::last_activity, metrics_mutex_, kcenon::network::error_codes::common_errors::not_initialized, kcenon::network::ok(), and pool_.

|
overridevirtual |
Check if the bridge is initialized.
Implements kcenon::network::integration::INetworkBridge.
Definition at line 89 of file thread_pool_bridge.cpp.
References initialized_, and pool_.
|
overridevirtual |
Shutdown the bridge.
Shuts down the bridge but does not shut down the underlying thread pool. Thread pool lifecycle is managed externally.
This method is idempotent - multiple calls are safe.
Implements kcenon::network::integration::INetworkBridge.
Definition at line 73 of file thread_pool_bridge.cpp.
References cached_metrics_, initialized_, kcenon::network::integration::BridgeMetrics::is_healthy, kcenon::network::integration::BridgeMetrics::last_activity, metrics_mutex_, and kcenon::network::ok().
Referenced by ~ThreadPoolBridge().


|
private |
Definition at line 247 of file thread_pool_bridge.h.
Referenced by get_backend_type(), get_metrics(), and initialize().
|
mutableprivate |
Definition at line 250 of file thread_pool_bridge.h.
Referenced by get_metrics(), initialize(), and shutdown().
|
private |
Definition at line 248 of file thread_pool_bridge.h.
Referenced by get_metrics(), initialize(), is_initialized(), shutdown(), and ~ThreadPoolBridge().
|
mutableprivate |
Definition at line 249 of file thread_pool_bridge.h.
Referenced by get_metrics(), initialize(), and shutdown().
|
private |
Definition at line 246 of file thread_pool_bridge.h.
Referenced by get_metrics(), get_thread_pool(), initialize(), is_initialized(), and ThreadPoolBridge().