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 285 of file NetworkSubsystem.cpp.

286{
287 auto* backend = get_backend(info.transport);
288 if (!backend) {
290 "No backend for transport {}", static_cast<int>(info.transport));
291 return 0;
292 }
293
294 EndpointInfo ep = info;
295 ep.id = m_next_endpoint_id.fetch_add(1);
296
297 uint64_t backend_id = backend->open_endpoint(ep);
298 if (backend_id == 0) {
299 return 0;
300 }
301
302 {
303 std::unique_lock lock(m_routing_mutex);
304 m_endpoint_routing[ep.id] = info.transport;
305 }
306
307 return ep.id;
308}
#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.