7#if KCENON_WITH_COMMON_SYSTEM
16 std::shared_ptr<thread_pool_interface> pool,
18 : pool_(std::move(pool)), backend_type_(backend_type) {
20 throw std::invalid_argument(
"ThreadPoolBridge requires non-null thread pool");
34 "ThreadPoolBridge already initialized",
35 "ThreadPoolBridge::initialize");
41 "Thread pool is null",
42 "ThreadPoolBridge::initialize");
45 if (!
pool_->is_running()) {
48 "Thread pool is not running",
49 "ThreadPoolBridge::initialize");
53 auto enabled_it =
config.properties.find(
"enabled");
54 if (enabled_it !=
config.properties.end() && enabled_it->second ==
"false") {
57 "Bridge is disabled in configuration",
58 "ThreadPoolBridge::initialize");
126 const std::string& pool_name) {
131 throw std::runtime_error(
"Failed to get thread pool from thread_integration_manager");
137#if KCENON_WITH_COMMON_SYSTEM
138std::shared_ptr<ThreadPoolBridge> ThreadPoolBridge::from_common_system(
139 std::shared_ptr<::kcenon::common::interfaces::IExecutor> executor) {
141 throw std::invalid_argument(
"ThreadPoolBridge::from_common_system requires non-null executor");
145 auto adapted_pool = std::make_shared<common_to_network_thread_adapter>(std::move(executor));
BackendType get_backend_type() const
Get the backend type.
VoidResult shutdown() override
Shutdown the bridge.
std::mutex metrics_mutex_
BackendType
Type of thread pool backend.
@ ThreadSystem
Uses thread_system's thread pool.
@ CommonSystem
Uses common_system's IExecutor.
BackendType backend_type_
static std::shared_ptr< ThreadPoolBridge > from_thread_system(const std::string &pool_name="network_pool")
Create bridge from thread_system.
ThreadPoolBridge(std::shared_ptr< thread_pool_interface > pool, BackendType backend_type=BackendType::Custom)
Construct bridge with custom thread pool.
bool is_initialized() const override
Check if the bridge is initialized.
std::shared_ptr< thread_pool_interface > pool_
std::shared_ptr< thread_pool_interface > get_thread_pool() const
Get the underlying thread pool.
BridgeMetrics get_metrics() const override
Get current metrics.
BridgeMetrics cached_metrics_
~ThreadPoolBridge() override
Destructor.
VoidResult initialize(const BridgeConfig &config) override
Initialize the bridge with configuration.
std::atomic< bool > initialized_
static thread_integration_manager & instance()
Get the singleton instance.
std::shared_ptr< thread_pool_interface > get_thread_pool()
Get the current thread pool.
constexpr int invalid_argument
constexpr int not_initialized
constexpr int already_exists
VoidResult error_void(int code, const std::string &message, const std::string &source="network_system", const std::string &details="")
Configuration for bridge initialization.
Metrics and health information for a bridge.
std::chrono::steady_clock::time_point last_activity
Timestamp of last activity or health check.
std::map< std::string, double > custom_metrics
Bridge-specific custom metrics.
bool is_healthy
Overall health status of the bridge.
Bidirectional adapters between network_system's thread_pool_interface and common_system's IExecutor/I...
Thread pool integration bridge for network_system.