49template <
typename Data>
86 Topic::CheckSubscriberType<Data>(topic);
92 block_->data_.buff_addr = &data;
93 block_->data_.copy_payload = &Topic::CopyPayload<Data>;
122 other.block_ =
nullptr;
140 other.block_ =
nullptr;
161 ASSERT(
block_ !=
nullptr);
163 auto& data =
block_->data_;
166 std::memory_order_acq_rel,
167 std::memory_order_acquire))
172 auto wait_ans = data.sem.Wait(timeout);
181 std::memory_order_acq_rel,
182 std::memory_order_acquire))
187 DEV_ASSERT(data.wait_state.load(std::memory_order_acquire) ==
193 finish_wait_ans = data.sem.Wait(UINT32_MAX);
数据节点模板,继承自 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 TopicHandle WaitTopic(const char *name, uint32_t timeout=UINT32_MAX, Domain *domain=nullptr)
等待指定名称的 topic 出现 / Wait until a topic with the given name exists
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ 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)
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.
MicrosecondTimestamp timestamp
这里对应那份数据的时间戳 / Timestamp paired with the buffered data.