MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ open_endpoint()

uint64_t MayaFlux::Core::NetworkSubsystem::open_endpoint ( const EndpointInfo info)

Open an endpoint on the backend matching info.transport.

Parameters
infoEndpoint configuration.
Returns
Globally unique endpoint id, or 0 on failure.

Definition at line 291 of file NetworkSubsystem.cpp.

292{
293 auto* backend = get_backend(info.transport);
294 if (!backend) {
296 "No backend for transport {}", static_cast<int>(info.transport));
297 return 0;
298 }
299
300 EndpointInfo ep = info;
301 ep.id = m_next_endpoint_id.fetch_add(1);
302
303 uint64_t backend_id = backend->open_endpoint(ep);
304 if (backend_id == 0) {
305 return 0;
306 }
307
308 {
309 std::unique_lock lock(m_routing_mutex);
310 m_endpoint_routing[ep.id] = info.transport;
311 }
312
313 return ep.id;
314}
#define MF_ERROR(comp, ctx,...)
std::shared_mutex m_routing_mutex
Maps endpoint_id -> transport for routing send/close/query to the correct backend without scanning al...
std::atomic< uint64_t > m_next_endpoint_id
Global endpoint id counter shared across all backends.
std::unordered_map< uint64_t, NetworkTransport > m_endpoint_routing
INetworkBackend * get_backend(NetworkTransport transport) const
Get a backend by transport type.
@ NetworkSubsystem
Network subsystem operations (endpoint management, data routing)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Core::EndpointInfo::id, MF_ERROR, MayaFlux::Journal::NetworkSubsystem, and MayaFlux::Core::EndpointInfo::transport.