VLink  2.0.0
A high-performance communication middleware
vlink::PublisherImpl类 参考abstract

Publish-side base shared by every transport-specific publisher. 更多...

#include <publisher_impl.h>

类 vlink::PublisherImpl 继承关系图:
vlink::PublisherImpl 的协作图:

Public 成员函数

 ~PublisherImpl () override
 Releases the helper state. 更多...
 
void interrupt () override
 Wakes waiters and forwards the interrupt to NodeImpl. 更多...
 
virtual void detect_subscribers (ConnectCallback &&callback)
 Registers callback to fire when subscriber presence changes. 更多...
 
virtual bool wait_for_subscribers (std::chrono::milliseconds timeout)
 Blocks until at least one subscriber is reachable or timeout elapses. 更多...
 
virtual bool has_subscribers () const =0
 Reports whether at least one subscriber is currently connected. 更多...
 
virtual bool write (const Bytes &msg_data)=0
 Publishes a serialised payload to every connected subscriber. 更多...
 
virtual bool write (const IntraData &intra_data)
 Publishes an in-process payload without serialisation. 更多...
 
void update_subscribers ()
 Notifies the base class that subscriber presence may have changed. 更多...
 

Protected 成员函数

 PublisherImpl ()
 Stamps the node as kPublisher and primes the helper state. 更多...
 

额外继承的成员函数

详细描述

Publish-side base shared by every transport-specific publisher.

Owns the helper condition variable and connect-callback storage that back Publisher<T>::wait_for_subscribers() and Publisher<T>::detect_subscribers(). Transports invoke update_subscribers() from their discovery threads whenever the subscriber count flips between zero and non-zero.

构造及析构函数说明

◆ ~PublisherImpl()

vlink::PublisherImpl::~PublisherImpl ( )
override

Releases the helper state.

◆ PublisherImpl()

vlink::PublisherImpl::PublisherImpl ( )
protected

Stamps the node as kPublisher and primes the helper state.

成员函数说明

◆ detect_subscribers()

virtual void vlink::PublisherImpl::detect_subscribers ( ConnectCallback &&  callback)
virtual

Registers callback to fire when subscriber presence changes.

The callback is invoked with true when the first subscriber appears and with false after the last one drops. When subscribers are already known at registration time the callback is primed with true before this function returns.

参数
callbackCallable void(bool) describing the new presence.

◆ has_subscribers()

virtual bool vlink::PublisherImpl::has_subscribers ( ) const
pure virtual

Reports whether at least one subscriber is currently connected.

Pure virtual; subclasses query their discovery handle. Used by both wait_for_subscribers() and update_subscribers() to detect state transitions.

返回
true when a subscriber is reachable.

◆ interrupt()

void vlink::PublisherImpl::interrupt ( )
overridevirtual

Wakes waiters and forwards the interrupt to NodeImpl.

Marks the node interrupted and notifies the helper condition variable so pending wait_for_subscribers() calls return false promptly.

重载 vlink::NodeImpl .

◆ update_subscribers()

void vlink::PublisherImpl::update_subscribers ( )

Notifies the base class that subscriber presence may have changed.

Compares has_subscribers() against the helper cache; on a transition the condition variable is signalled and the stored ConnectCallback is invoked. Intended for use from transport discovery threads.

◆ wait_for_subscribers()

virtual bool vlink::PublisherImpl::wait_for_subscribers ( std::chrono::milliseconds  timeout)
virtual

Blocks until at least one subscriber is reachable or timeout elapses.

Returns immediately when has_subscribers() already reports true. Negative timeouts (e.g. Timeout::kInfinite) wait indefinitely.

参数
timeoutWait budget; negative disables the deadline.
返回
true when a subscriber arrived in time; false otherwise.

◆ write() [1/2]

virtual bool vlink::PublisherImpl::write ( const Bytes msg_data)
pure virtual

Publishes a serialised payload to every connected subscriber.

Pure virtual. msg_data is produced by Serializer::serialize() at the public layer.

参数
msg_dataSerialised payload bytes.
返回
true when the frame was successfully delivered or queued.

◆ write() [2/2]

virtual bool vlink::PublisherImpl::write ( const IntraData intra_data)
virtual

Publishes an in-process payload without serialisation.

Default implementation warns and returns false; only IntraPublisherImpl forwards the shared payload directly to co-located subscribers.

参数
intra_dataShared payload pointer.
返回
true when the message was dispatched; false otherwise.

该类的文档由以下文件生成: