Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
thread_pool_bridge.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6#ifndef KCENON_NETWORK_INTERNAL_INTEGRATION_THREAD_POOL_BRIDGE_H_
7#define KCENON_NETWORK_INTERNAL_INTEGRATION_THREAD_POOL_BRIDGE_H_
8
45#include <memory>
46#include <string>
47#include <mutex>
48#include <atomic>
49
50#if KCENON_WITH_COMMON_SYSTEM
51#include <kcenon/common/interfaces/executor_interface.h>
52#endif
53
55
82public:
87 enum class BackendType {
90 Custom
91 };
92
105 explicit ThreadPoolBridge(
106 std::shared_ptr<thread_pool_interface> pool,
107 BackendType backend_type = BackendType::Custom);
108
114 ~ThreadPoolBridge() override;
115
116 // INetworkBridge interface implementation
117
146 VoidResult initialize(const BridgeConfig& config) override;
147
157 VoidResult shutdown() override;
158
163 bool is_initialized() const override;
164
176 BridgeMetrics get_metrics() const override;
177
178 // ThreadPoolBridge-specific methods
179
193 std::shared_ptr<thread_pool_interface> get_thread_pool() const;
194
200
201 // Factory methods
202
219 static std::shared_ptr<ThreadPoolBridge> from_thread_system(
220 const std::string& pool_name = "network_pool");
221
222#if KCENON_WITH_COMMON_SYSTEM
241 static std::shared_ptr<ThreadPoolBridge> from_common_system(
242 std::shared_ptr<::kcenon::common::interfaces::IExecutor> executor);
243#endif
244
245private:
246 std::shared_ptr<thread_pool_interface> pool_;
248 std::atomic<bool> initialized_{false};
249 mutable std::mutex metrics_mutex_;
251};
252
253} // namespace kcenon::network::integration
254
255// Backward compatibility namespace alias
256namespace network_system {
258}
259
260#endif // KCENON_NETWORK_INTERNAL_INTEGRATION_THREAD_POOL_BRIDGE_H_
Unified interface for external system integration bridges.
Abstract interface for external system integration bridges.
Bridge for thread pool integration implementing INetworkBridge.
BackendType get_backend_type() const
Get the backend type.
VoidResult shutdown() override
Shutdown the bridge.
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.
Feature flags for network_system.
VoidResult initialize()
Initialize the network system with default production configuration.
Configuration for bridge initialization.
Metrics and health information for a bridge.
Thread system integration interface for network_system.