15 DATA_READY = UINT32_MAX
28 std::atomic<ASyncSubscriberState>
state =
38template <
typename Data>
96 other.block_ =
nullptr;
114 other.block_ =
nullptr;
125 return block_->data_.state.load(std::memory_order_acquire) ==
141 if (
block_->data_.state.load(std::memory_order_acquire) ==
146 return *
reinterpret_cast<Data*
>(
block_->data_.buff_addr);
163 if (
block_->data_.state.load(std::memory_order_acquire) ==
167 std::memory_order_release);
数据节点模板,继承自 BaseNode,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data...
Data data_
存储的数据。 The stored data.
微秒时间戳 / Microsecond timestamp
Data data_
存储的数据 (Stored data).
先 StartWaiting(),再自己来取数据的订阅者 / Subscriber that first calls StartWaiting() and later pulls the data it...
ASyncSubscriber(Topic topic)
通过 Topic 句柄构造异步订阅者 / Construct an asynchronous subscriber from a Topic handle
ASyncSubscriber(ASyncSubscriber &&other) noexcept
移动构造异步订阅者 / Move-construct one asynchronous subscriber
ASyncSubscriber(const ASyncSubscriber &other)=delete
禁止拷贝异步订阅者 / Copy construction is disabled for asynchronous subscribers
Data & GetData()
获取当前数据 / Retrieve the current data
ASyncSubscriber & operator=(const ASyncSubscriber &other)=delete
禁止拷贝赋值异步订阅者 / Copy assignment is disabled for asynchronous subscribers
LockFreeList::Node< ASyncBlock > * block_
订阅者数据块。Subscriber data block.
bool Available()
检查数据是否可用 / Check whether data is available
MicrosecondTimestamp GetTimestamp() const
获取最近一次接收的消息时间戳 / Get the latest received message timestamp
ASyncSubscriber(const char *name, Domain *domain=nullptr)
通过主题名称构造异步订阅者 / Construct an asynchronous subscriber by topic name
ASyncSubscriber & operator=(ASyncSubscriber &&other) noexcept
移动赋值异步订阅者 / Move-assign one asynchronous subscriber
void StartWaiting()
开始等待数据更新 / Start waiting for a data update
topic 所属的命名域 / Naming domain that groups topics
发布订阅主题 / Publish-subscribe topic
@ ASYNC
异步本地缓冲型订阅者。Asynchronous local-buffer subscriber.
static void * AllocateSubscriberBuffer()
为订阅者分配一个长期存在的本地接收对象 / Allocate one long-lived local receive object for a subscriber
ASyncSubscriberState
异步订阅者本地缓冲区的状态 / State of the async subscriber's local buffer
@ WAITING
等待下一次发布填充本地缓冲区。Waiting for the next publish to fill the local buffer.
@ DATA_READY
本地缓冲区已有一份待消费的新数据。One unread fresh sample is buffered locally.
@ IDLE
当前没有等待,也没有待消费的新数据。No wait is pending and no unread data is buffered.
static void CopyPayload(void *dst, void *payload_addr)
按精确类型把一份 payload 拷到订阅者缓冲区 / Copy one payload into a subscriber buffer using the exact type
static void CheckSubscriberType(Topic topic)
断言订阅者看到的精确 payload 类型与 topic 契约一致 / Assert that the exact payload type seen by a subscriber matches t...
static TopicHandle WaitTopic(const char *name, uint32_t timeout=UINT32_MAX, Domain *domain=nullptr)
等待指定名称的 topic 出现 / Wait until a topic with the given name exists
TopicHandle block_
当前 topic 视图绑定的状态块。Runtime state block bound to the current topic view.
异步订阅者自己挂的数据块 / Data block owned by one asynchronous subscriber
std::atomic< ASyncSubscriberState > state
当前异步订阅状态。Current async subscriber state.
void * buff_addr
长期存在的本地接收对象地址。Long-lived local receive object address.
void(* copy_payload)(void *dst, void *payload_addr)
按订阅精确类型执行负载拷贝的适配函数。Adapter that copies one payload using the subscriber's exact type.
MicrosecondTimestamp timestamp
最近接收的消息时间戳。Latest received message timestamp.
所有订阅块共用的公共头 / Common header shared by all subscriber blocks