7#include <asio/executor_work_guard.hpp>
8#include <asio/io_context.hpp>
74 void register_callbacks()
override;
76 void start()
override;
77 void pause()
override;
78 void resume()
override;
80 void shutdown()
override;
83 [[nodiscard]]
bool is_ready()
const override {
return m_ready.load(); }
84 [[nodiscard]]
bool is_running()
const override {
return m_running.load(); }
99 bool add_backend(std::unique_ptr<INetworkBackend> backend);
109 [[nodiscard]] std::vector<INetworkBackend*> get_backends()
const;
125 void close_endpoint(uint64_t endpoint_id);
130 bool send(uint64_t endpoint_id,
const uint8_t* data,
size_t size);
135 bool send_to(uint64_t endpoint_id,
const uint8_t* data,
size_t size,
136 const std::string& address, uint16_t port);
141 [[nodiscard]]
EndpointState get_endpoint_state(uint64_t endpoint_id)
const;
149 void set_endpoint_receive_callback(uint64_t endpoint_id,
155 [[nodiscard]] std::vector<EndpointInfo> get_all_endpoints()
const;
162 std::atomic<bool> m_ready {
false };
163 std::atomic<bool> m_running {
false };
177 std::unique_ptr<asio::executor_work_guard<asio::io_context::executor_type>>
m_work_guard;
179#if MAYAFLUX_USE_JTHREAD
180 std::jthread m_io_thread;
183 std::atomic<bool> m_io_stop_requested {
false };
187 std::unordered_map<NetworkTransport, std::unique_ptr<INetworkBackend>>
m_backends;
211 std::atomic<uint64_t> m_next_endpoint_id { 1 };
213 void initialize_udp_backend();
214 void initialize_tcp_backend();
215 void initialize_shm_backend();
217 void register_backend_service();
223 void on_backend_receive(uint64_t endpoint_id,
const uint8_t* data,
224 size_t size, std::string_view sender_addr);
Abstract interface for network transport backends.
Base interface for all subsystems in the MayaFlux processing architecture.
std::unique_ptr< asio::io_context > m_io_context
GlobalNetworkConfig m_config
std::shared_mutex m_backends_mutex
std::shared_mutex m_routing_mutex
Maps endpoint_id -> transport for routing send/close/query to the correct backend without scanning al...
bool is_running() const override
Check if subsystem is currently processing.
std::unique_ptr< asio::executor_work_guard< asio::io_context::executor_type > > m_work_guard
NetworkSubsystem & operator=(const NetworkSubsystem &)=delete
SubsystemProcessingHandle * get_processing_context_handle() override
Get the processing context handle for this subsystem.
std::unordered_map< uint64_t, NetworkTransport > m_endpoint_routing
SubsystemTokens get_tokens() const override
Get the processing token configuration this subsystem manages.
NetworkSubsystem(const NetworkSubsystem &)=delete
std::unordered_map< uint64_t, NetworkReceiveCallback > m_endpoint_callbacks
std::shared_mutex m_callbacks_mutex
Per-endpoint receive callbacks set by consumers via set_endpoint_receive_callback().
NetworkSubsystem & operator=(NetworkSubsystem &&)=delete
bool is_ready() const override
Check if subsystem is ready for operation.
SubsystemType get_type() const override
Get the type of this subsystem.
NetworkSubsystem(NetworkSubsystem &&)=delete
std::unordered_map< NetworkTransport, std::unique_ptr< INetworkBackend > > m_backends
std::shared_ptr< Registry::Service::NetworkService > m_network_service
General-purpose network transport subsystem.
Unified interface combining buffer and node processing for subsystems.
EndpointState
Observable connection state for an endpoint.
NetworkTransport
Identifies the transport protocol a backend implements.
std::function< void(uint64_t endpoint_id, const uint8_t *data, size_t size, std::string_view sender_addr)> NetworkReceiveCallback
Callback signature for inbound data on an endpoint.
Describes one logical send/receive endpoint managed by a backend.
Configuration for the NetworkSubsystem.
Processing token configuration for subsystem operation.