44template <
typename Data>
84 block_->data_.buff_addr = &data;
114 other.block_ =
nullptr;
132 other.block_ =
nullptr;
153 ASSERT(
block_ !=
nullptr);
155 auto& data =
block_->data_;
158 std::memory_order_acq_rel,
159 std::memory_order_acquire))
164 auto wait_ans = data.sem.Wait(timeout);
173 std::memory_order_acq_rel,
174 std::memory_order_acquire))
181 auto finish_wait_ans = data.sem.Wait(UINT32_MAX);
182 UNUSED(finish_wait_ans);
数据节点模板,继承自 BaseNode,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data...
Data data_
存储的数据。 The stored data.
微秒时间戳 / Microsecond timestamp
Data data_
存储的数据 (Stored data).
信号量类,实现线程同步机制 Semaphore class implementing thread synchronization
topic 所属的命名域 / Naming domain that groups topics
调用 Wait() 收消息的订阅者 / Subscriber that receives messages by calling Wait()
SyncSubscriber(Topic topic, Data &data)
通过 Topic 句柄构造同步订阅者 / Construct a synchronous subscriber using a Topic handle
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待接收数据 / Wait for data reception
LockFreeList::Node< SyncBlock > * block_
订阅者数据块。Subscriber data block.
SyncSubscriber & operator=(const SyncSubscriber &other)=delete
禁止拷贝赋值同步订阅者 / Copy assignment is disabled for synchronous subscribers
MicrosecondTimestamp GetTimestamp() const
获取最近一次接收的消息时间戳 / Get the latest received message timestamp
SyncSubscriber(const char *name, Data &data, Domain *domain=nullptr)
通过主题名称构造同步订阅者 / Construct a synchronous subscriber by topic name
SyncSubscriber(SyncSubscriber &&other) noexcept
移动构造同步订阅者 / Move-construct one synchronous subscriber
SyncSubscriber & operator=(SyncSubscriber &&other) noexcept
移动赋值同步订阅者 / Move-assign one synchronous subscriber
SyncSubscriber(const SyncSubscriber &other)=delete
禁止拷贝同步订阅者 / Copy construction is disabled for synchronous subscribers
发布订阅主题 / Publish-subscribe topic
@ SYNC
同步等待型订阅者。Synchronous wait-based subscriber.
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.
@ OK
操作成功 | Operation successful
所有订阅块共用的公共头 / Common header shared by all subscriber blocks
同步订阅者自己挂的数据块 / Data block owned by one synchronous subscriber
void(* copy_payload)(void *dst, void *payload_addr)
按订阅精确类型执行负载拷贝的适配函数。Adapter that copies one payload using the subscriber's exact type.
void * buff_addr
收到消息后要拷到这里。Received payloads are copied here.
std::atomic< uint32_t > wait_state
当前 Wait() 的挂起状态。Current pending state of Wait().
Semaphore sem
用来唤醒 Wait() 的信号量。Semaphore used to wake Wait().
WaitState
同步等待状态 / Synchronous wait state
@ WAIT_IDLE
当前没有挂起等待。No wait is currently pending.
@ WAITING
当前有一个挂起的等待者。One waiter is currently pending.
@ WAIT_CLAIMED
某次发布已归一个刚超时的等待者所有。One publish wakeup is reserved for a waiter that just timed out.
MicrosecondTimestamp timestamp
这里对应那份数据的时间戳。Timestamp paired with the buffered data.