Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_transport
  6. pw::transport::ForwardingTransport Class Reference
pw::transport::ForwardingTransport Class Referencefinal

Overview

An in-memory ReliableListener and ReliableConnector that pairs outbound Connect() calls with inbound Accept() calls.

Each matched Connect() and Accept() creates a connected pair of in-memory ReliableSockets allocated from allocator that forward datagrams to each other without copying.

Connect() and Accept() may be called in either order and from multiple tasks concurrently. Unmatched calls remain pending in FIFO order until a peer call arrives or the future is canceled; no sockets are allocated until both sides are present. If allocator cannot allocate the sockets, pending Connect() futures resolve to RESOURCE_EXHAUSTED while the listener remains active for subsequent connections.

On destruction, any still-pending Accept() and Connect() futures resolve to FAILED_PRECONDITION. Sockets from already-established connections remain open; allocator must outlive them and must not block (both sockets in a connection share an InterruptSpinLock, and allocator is called while that lock is held).

Inheritance diagram for pw::transport::ForwardingTransport:
pw::transport::ReliableListener pw::transport::ReliableConnector pw::transport::Listener pw::transport::Connector

Public Member Functions

 ForwardingTransport (Allocator &allocator, const ForwardingSocketOptions &options={})
 
 ~ForwardingTransport () override
 
 ForwardingTransport (const ForwardingTransport &)=delete
 
ForwardingTransport & operator= (const ForwardingTransport &)=delete
 
 ForwardingTransport (ForwardingTransport &&)=delete
 
ForwardingTransport & operator= (ForwardingTransport &&)=delete
 
- Public Member Functions inherited from pw::transport::ReliableListener
AcceptFuture Accept ()
 
- Public Member Functions inherited from pw::transport::Listener
AcceptFuture Accept ()
 
- Public Member Functions inherited from pw::transport::ReliableConnector
ConnectFuture Connect ()
 
- Public Member Functions inherited from pw::transport::Connector
ConnectFuture Connect ()
 

Private Member Functions

ReliableListener::AcceptFuture DoAcceptReliable () override
 Implements accepting a reliable inbound connection from a peer.
 
ReliableConnector::ConnectFuture DoConnectReliable () override
 Implements opening a reliable outbound connection to the peer.
 

Additional Inherited Members

- Protected Types inherited from pw::transport::ReliableListener
using AcceptProvider = internal::TransportFutureProvider< AcceptFuture >
 One-to-one provider that vends AcceptFuture instances.
 
using AcceptListProvider = internal::TransportFutureListProvider< AcceptFuture >
 
- Protected Types inherited from pw::transport::Listener
using AcceptProvider = internal::TransportFutureProvider< AcceptFuture >
 One-to-one provider that vends AcceptFuture instances.
 
using AcceptListProvider = internal::TransportFutureListProvider< AcceptFuture >
 
- Protected Types inherited from pw::transport::ReliableConnector
using ConnectProvider = internal::TransportFutureProvider< ConnectFuture >
 One-to-one provider that vends ConnectFuture instances.
 
using ConnectListProvider = internal::TransportFutureListProvider< ConnectFuture >
 
- Protected Types inherited from pw::transport::Connector
using ConnectProvider = internal::TransportFutureProvider< ConnectFuture >
 One-to-one provider that vends ConnectFuture instances.
 
using ConnectListProvider = internal::TransportFutureListProvider< ConnectFuture >
 
- Static Protected Member Functions inherited from pw::transport::ReliableListener
static ReliableSocket WrapSocket (ReliableSocketImpl &impl)
 Creates a ReliableSocket handle from an implementation.
 
- Static Protected Member Functions inherited from pw::transport::Listener
static Socket WrapSocket (SocketImpl &impl)
 Creates a Socket handle from an implementation.
 
- Static Protected Member Functions inherited from pw::transport::ReliableConnector
static ReliableSocket WrapSocket (ReliableSocketImpl &impl)
 Creates a ReliableSocket handle from an implementation.
 
- Static Protected Member Functions inherited from pw::transport::Connector
static Socket WrapSocket (SocketImpl &impl)
 Creates a Socket handle from an implementation.
 

Constructor & Destructor Documentation

◆ ForwardingTransport()

pw::transport::ForwardingTransport::ForwardingTransport ( Allocator &  allocator,
const ForwardingSocketOptions &  options = {} 
)
explicit

Creates an in-memory transport that allocates connected sockets and their buffers from allocator using options.

Parameters
[in,out]allocatorAllocator used for socket endpoints, queues, and write buffers.
[in]optionsQueue depth and maximum message size for each established connection.
Precondition
options.queue_depth > 0 (crash-asserts otherwise).
allocator must outlive this ForwardingTransport and all sockets produced by it, and must not block.

◆ ~ForwardingTransport()

pw::transport::ForwardingTransport::~ForwardingTransport ( )
override

Resolves any pending Accept() and Connect() futures with FAILED_PRECONDITION. Sockets from already-established connections remain open.

Member Function Documentation

◆ DoAcceptReliable()

ReliableListener::AcceptFuture pw::transport::ForwardingTransport::DoAcceptReliable ( )
overrideprivatevirtual

Implements accepting a reliable inbound connection from a peer.

Implements pw::transport::ReliableListener.

◆ DoConnectReliable()

ReliableConnector::ConnectFuture pw::transport::ForwardingTransport::DoConnectReliable ( )
overrideprivatevirtual

Implements opening a reliable outbound connection to the peer.

Implements pw::transport::ReliableConnector.


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