DelegateMQ
Loading...
Searching...
No Matches
TransportMonitor Class Reference

A thread-safe monitor for tracking outgoing remote messages and detecting timeouts. More...

#include <TransportMonitor.h>

Inheritance diagram for TransportMonitor:
ITransportMonitor

Public Types

enum class  Status { SUCCESS , TIMEOUT }
 

Public Member Functions

 TransportMonitor (const dmq::Duration timeout)
 
 ~TransportMonitor ()
 
virtual void Add (uint16_t seqNum, dmq::DelegateRemoteId remoteId) override
 
virtual void Remove (uint16_t seqNum) override
 
void Process ()
 Call periodically to process message timeouts.
 
- Public Member Functions inherited from ITransportMonitor

Public Attributes

std::shared_ptr< dmq::SignalSafe< void(dmq::DelegateRemoteId, uint16_t, Status)> > OnSendStatus
 

Detailed Description

A thread-safe monitor for tracking outgoing remote messages and detecting timeouts.

The TransportMonitor implements the reliability layer for remote delegate invocations. It tracks "in-flight" messages by their sequence number and timestamps them upon sending.

Key Responsibilities:

  • Timeout Detection: Identifies messages that have not been acknowledged within the configured TRANSPORT_TIMEOUT duration.
  • Status Reporting: Invokes the SendStatusCb delegate with Status::SUCCESS (upon ACK) or Status::TIMEOUT (upon expiration) to notify the application.
  • Thread Safety: Internal state is protected by a recursive mutex, allowing safe access from multiple threads (e.g., sending thread vs. ACK receiving thread).

Usage Note: This class relies on a cooperative polling model. The Process() method must be called periodically (typically by a background timer or the network thread loop) to scan for and handle expired messages.

Member Enumeration Documentation

◆ Status

enum class TransportMonitor::Status
strong
Enumerator
SUCCESS 
TIMEOUT 

Constructor & Destructor Documentation

◆ TransportMonitor()

TransportMonitor::TransportMonitor ( const dmq::Duration timeout)
inline

◆ ~TransportMonitor()

TransportMonitor::~TransportMonitor ( )
inline

Member Function Documentation

◆ Add()

virtual void TransportMonitor::Add ( uint16_t seqNum,
dmq::DelegateRemoteId remoteId )
inlineoverridevirtual

Add a sequence number param[in] seqNum - the delegate message sequence number param[in] remoteId - the remote ID

Implements ITransportMonitor.

◆ Process()

void TransportMonitor::Process ( )
inline

Call periodically to process message timeouts.

◆ Remove()

virtual void TransportMonitor::Remove ( uint16_t seqNum)
inlineoverridevirtual

Remove a sequence number. Invokes SendStatusCb callback to notify registered client of removal. param[in] seqNum - the delegate message sequence number

Implements ITransportMonitor.

Member Data Documentation

◆ OnSendStatus

std::shared_ptr<dmq::SignalSafe<void(dmq::DelegateRemoteId, uint16_t, Status)> > TransportMonitor::OnSendStatus

Signal emitted when a message status is determined. Subscribers receive: (remoteId, seqNum, status) Use a shared_ptr for the signal as required by SignalSafe


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