VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::SubscriberImpl Class Referenceabstract

Transport-agnostic base for subscriber node implementations. More...

#include <subscriber_impl.h>

Inheritance diagram for vlink::SubscriberImpl:
Collaboration diagram for vlink::SubscriberImpl:

Public Member Functions

 ~SubscriberImpl () override
 Destructor.
virtual bool listen (MsgCallback &&callback)=0
 Registers the serialised-message receive callback.
virtual bool listen (IntraMsgCallback &&callback)
 Registers the zero-copy in-process receive callback.
virtual void set_latency_and_lost_enabled (bool enable)
 Enables or disables per-message latency and sample-loss tracking.
virtual bool is_latency_and_lost_enabled () const
 Returns whether latency and sample-loss tracking is currently enabled.
virtual int64_t get_latency () const
 Returns the most recently measured end-to-end message latency in microseconds.
virtual SampleLostInfo get_lost () const
 Returns cumulative sample delivery statistics.

Public Attributes

bool is_listened {false}
 true after listen() has been successfully called.

Protected Member Functions

 SubscriberImpl ()
 Protected constructor; initialises the subscriber with kSubscriber role.

Additional Inherited Members

Detailed Description

Transport-agnostic base for subscriber node implementations.

Provides default (no-op) implementations for the optional latency/loss tracking interface. Concrete transport backends override listen(MsgCallback&&) to register their receive callback and, optionally, override the latency/loss methods if the transport provides that information.

Constructor & Destructor Documentation

◆ ~SubscriberImpl()

vlink::SubscriberImpl::~SubscriberImpl ( )
override

Destructor.

◆ SubscriberImpl()

vlink::SubscriberImpl::SubscriberImpl ( )
protected

Protected constructor; initialises the subscriber with kSubscriber role.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ get_latency()

virtual int64_t vlink::SubscriberImpl::get_latency ( ) const
nodiscardvirtual

Returns the most recently measured end-to-end message latency in microseconds.

Only meaningful when is_latency_and_lost_enabled() returns true. The default implementation returns 0. Transports that support latency measurement override this to return the measured value.

Returns
Latency in microseconds, or 0 if tracking is disabled or unsupported.

◆ get_lost()

virtual SampleLostInfo vlink::SubscriberImpl::get_lost ( ) const
nodiscardvirtual

Returns cumulative sample delivery statistics.

Returns the total number of expected samples and the number that were lost due to queue overflow or network gaps. Only meaningful when is_latency_and_lost_enabled() returns true. The default implementation returns a zero-initialised SampleLostInfo.

Returns
SampleLostInfo containing total and lost counts.

◆ is_latency_and_lost_enabled()

virtual bool vlink::SubscriberImpl::is_latency_and_lost_enabled ( ) const
nodiscardvirtual

Returns whether latency and sample-loss tracking is currently enabled.

The default implementation always returns false. Transports that support tracking override this to reflect the current enabled state.

Returns
true if tracking is active; false otherwise.

◆ listen() [1/2]

virtual bool vlink::SubscriberImpl::listen ( IntraMsgCallback && callback)
virtual

Registers the zero-copy in-process receive callback.

Used exclusively on the intra:// transport to receive IntraData directly from a co-located publisher without serialisation. The default implementation logs a warning and returns false; only IntraSubscriberImpl overrides this.

Parameters
callbackCallable void(const IntraData&) invoked on every received in-process message.
Returns
true if registration succeeded; false if this transport does not support IntraData.

◆ listen() [2/2]

virtual bool vlink::SubscriberImpl::listen ( MsgCallback && callback)
pure virtual

Registers the serialised-message receive callback.

Must be implemented by each concrete transport backend. The callback is invoked with a Bytes buffer containing the raw serialised message each time a new message arrives. After registration is_listened is set to true by the Subscriber<T> layer.

Parameters
callbackCallable void(const Bytes&) invoked on every received message.
Returns
true if registration succeeded; false on error.

◆ set_latency_and_lost_enabled()

virtual void vlink::SubscriberImpl::set_latency_and_lost_enabled ( bool enable)
virtual

Enables or disables per-message latency and sample-loss tracking.

When enabled, the transport backend tracks message timestamps (for latency) and sequence numbers (for loss detection). The default implementation is a no-op; transports that support tracking override this method.

Parameters
enabletrue to enable tracking; false to disable.

Member Data Documentation

◆ is_listened

bool vlink::SubscriberImpl::is_listened {false}

true after listen() has been successfully called.


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