IBufferExchange Class Reference

Space-ng SDK: sol3::core::IBufferExchange Class Reference
Space-ng SDK
sol3::core::IBufferExchange Class Referenceabstract

Interface for registering, discovering, and disposing shared buffers. More...

#include <sol3/core/shmem_buffer.h>

Inheritance diagram for sol3::core::IBufferExchange:
sol3::core::ShmemExchange

Public Types

using Endpoint = boost::asio::local::datagram_protocol::endpoint
 
using EndpointPort = sol3::core::EndpointPort
 
using PortIdx = sol3::core::PortIdx
 

Public Member Functions

virtual ~IBufferExchange ()=default
 
virtual void start ()=0
 Start running in a background thread. More...
 
virtual void stop ()=0
 Request the event loop to stop. More...
 
virtual bool stopped () const =0
 True if the exchange has been stopped. More...
 
virtual Endpoint const & localEndpoint () const =0
 Local endpoint used by this exchange. More...
 
virtual void addPeer (Endpoint const &peer_endpoint)=0
 
virtual void mapLocalToPeer (uint32_t local_port, Endpoint peer_endpoint, uint32_t peer_port=0)=0
 
virtual void configure (msg::ExchangeConfigT const &config)=0
 
virtual void listPorts (std::vector< EndpointPort > &ports) const =0
 List all ports this exchange has received from peers or shared locally. More...
 
virtual void registerBuffer (IBufferMutable const &buffer)=0
 
virtual void unregisterBuffer (IBufferMutable const &buffer)=0
 Unregister a previously shared mutable buffer. More...
 
virtual std::shared_ptr< IBufferConstget (uint32_t id, uint32_t idx) const =0
 
virtual std::shared_ptr< IBufferConstget (Endpoint const &ep, uint32_t id, uint32_t idx) const =0
 
virtual void dispose (std::shared_ptr< IBufferConst > &&buffer)=0
 Release resources associated with a previously retrieved buffer. More...
 
virtual void listMappings (std::map< uint32_t, std::vector< std::pair< Endpoint, uint32_t >>> &mappings) const =0
 
virtual void listResolvedBuffers (std::map< PortIdx, std::shared_ptr< IBufferConst >> &buffers) const =0
 

Static Public Member Functions

static std::shared_ptr< IBufferExchangemakeProcessLocal ()
 

Detailed Description

Interface for registering, discovering, and disposing shared buffers.

Member Typedef Documentation

◆ Endpoint

using sol3::core::IBufferExchange::Endpoint = boost::asio::local::datagram_protocol::endpoint

◆ EndpointPort

◆ PortIdx

Constructor & Destructor Documentation

◆ ~IBufferExchange()

virtual sol3::core::IBufferExchange::~IBufferExchange ( )
virtualdefault

Member Function Documentation

◆ addPeer()

virtual void sol3::core::IBufferExchange::addPeer ( Endpoint const &  peer_endpoint)
pure virtual

Add a peer endpoint to poll for its shared buffers.

The endpoint is expected to be the path on disk of the peer's UNIX domain socket.

Implemented in sol3::core::ShmemExchange.

◆ configure()

virtual void sol3::core::IBufferExchange::configure ( msg::ExchangeConfigT const &  config)
pure virtual

Apply configuration to this exchange.

Replaces previously configured mappings.

Wildcard fallback behavior is expressed using mappings with local_port == 0 and peer_port == 0.

Implemented in sol3::core::ShmemExchange.

◆ dispose()

virtual void sol3::core::IBufferExchange::dispose ( std::shared_ptr< IBufferConst > &&  buffer)
pure virtual

Release resources associated with a previously retrieved buffer.

Implemented in sol3::core::ShmemExchange.

◆ get() [1/2]

virtual std::shared_ptr<IBufferConst> sol3::core::IBufferExchange::get ( Endpoint const &  ep,
uint32_t  id,
uint32_t  idx 
) const
pure virtual

Retrieve a shared buffer from a specific endpoint only.

This direct endpoint lookup does not apply resolution rules.

Implemented in sol3::core::ShmemExchange.

◆ get() [2/2]

virtual std::shared_ptr<IBufferConst> sol3::core::IBufferExchange::get ( uint32_t  id,
uint32_t  idx 
) const
pure virtual

Retrieve a shared buffer by port according to resolution rules.

Resolution order when one or more mappings exist: 1) explicit local-to-peer mappings, in registration order 2) wildcard fallback mappings (local_port_to_peer_ports[0]), in registration order 3) this exchange's local endpoint:port

idx is the index of the shared buffer associated with the port. For MessageInput/MessageOutput buffers, this is typically 0.

Implemented in sol3::core::ShmemExchange.

◆ listMappings()

virtual void sol3::core::IBufferExchange::listMappings ( std::map< uint32_t, std::vector< std::pair< Endpoint, uint32_t >>> &  mappings) const
pure virtual

Returns the current local-port-to-peer routing table.

Keyed by local port (0 = wildcard fallback). Each entry is an ordered list of (peer_endpoint, peer_port) pairs applied in registration order.

Implemented in sol3::core::ShmemExchange.

◆ listPorts()

virtual void sol3::core::IBufferExchange::listPorts ( std::vector< EndpointPort > &  ports) const
pure virtual

List all ports this exchange has received from peers or shared locally.

Implemented in sol3::core::ShmemExchange.

◆ listResolvedBuffers()

virtual void sol3::core::IBufferExchange::listResolvedBuffers ( std::map< PortIdx, std::shared_ptr< IBufferConst >> &  buffers) const
pure virtual

Returns resolved buffers, keyed by PortIdx.

Each buffer carries its source endpoint() and info().id().

Implemented in sol3::core::ShmemExchange.

◆ localEndpoint()

virtual Endpoint const& sol3::core::IBufferExchange::localEndpoint ( ) const
pure virtual

Local endpoint used by this exchange.

Implemented in sol3::core::ShmemExchange.

◆ makeProcessLocal()

static std::shared_ptr<IBufferExchange> sol3::core::IBufferExchange::makeProcessLocal ( )
static

Constructs a local only buffer exchange, that does not share file descriptors over a unix domain socket.

◆ mapLocalToPeer()

virtual void sol3::core::IBufferExchange::mapLocalToPeer ( uint32_t  local_port,
Endpoint  peer_endpoint,
uint32_t  peer_port = 0 
)
pure virtual

Add a resolution rule from a local logical buffer port to a peer endpoint/port tuple.

You can add more than one mapping per local_port; mappings are applied in registration order.

local_port and peer_port are typically computed by MessagePort::encoded().

Wildcard mappings:

  • local_port == 0 matches any requested local port.
  • peer_port == 0 means "use the requested local port". This is useful for fallback routing like (0 -> peer, 0).

Implemented in sol3::core::ShmemExchange.

◆ registerBuffer()

virtual void sol3::core::IBufferExchange::registerBuffer ( IBufferMutable const &  buffer)
pure virtual

Registers a mutable buffer to be shared with requesting peers.

The buffer is only shared in response to requests from other peers, and is not automatically shared with peers that this exchange polls.

The underlying shared-memory storage is kept alive for this exchange, and for any peer exchange that has received it.

Implemented in sol3::core::ShmemExchange.

◆ start()

virtual void sol3::core::IBufferExchange::start ( )
pure virtual

Start running in a background thread.

Implemented in sol3::core::ShmemExchange.

◆ stop()

virtual void sol3::core::IBufferExchange::stop ( )
pure virtual

Request the event loop to stop.

Implemented in sol3::core::ShmemExchange.

◆ stopped()

virtual bool sol3::core::IBufferExchange::stopped ( ) const
pure virtual

True if the exchange has been stopped.

Implemented in sol3::core::ShmemExchange.

◆ unregisterBuffer()

virtual void sol3::core::IBufferExchange::unregisterBuffer ( IBufferMutable const &  buffer)
pure virtual

Unregister a previously shared mutable buffer.

Implemented in sol3::core::ShmemExchange.


The documentation for this class was generated from the following file: