Definition at line 312 of file subscriber.hpp.
◆ QueuedSubscriber() [1/5]
template<typename Data >
| LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
const char * | name, |
|
|
LockFreeQueue< Data > & | queue, |
|
|
Domain * | domain = nullptr ) |
|
inline |
构造函数,自动创建队列
- Template Parameters
-
| Data | 队列存储的数据类型 Data type stored in the queue |
- Parameters
-
| name | 订阅的主题名称 Name of the subscribed topic |
| queue | 订阅的数据队列 Subscribed data queue |
| domain | 可选的域指针 Optional domain pointer (default: nullptr) |
- Note
- 包含初始化期动态内存分配,订阅者应长期存在。 Contains initialization-time dynamic allocation; subscribers are expected to be long-lived.
Definition at line 328 of file subscriber.hpp.
330 {
331 }
QueuedSubscriber(const char *name, LockFreeQueue< Data > &queue, Domain *domain=nullptr)
构造函数,自动创建队列
static TopicHandle WaitTopic(const char *name, uint32_t timeout=UINT32_MAX, Domain *domain=nullptr)
等待主题的创建并返回其句柄 Waits for a topic to be created and returns its handle
Topic()
默认构造函数,创建一个空的 Topic 实例 Default constructor, creates an empty Topic instance
◆ QueuedSubscriber() [2/5]
template<typename Data >
| LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
const char * | name, |
|
|
LockFreeQueue< Message< Data > > & | queue, |
|
|
Domain * | domain = nullptr ) |
|
inline |
构造函数,使用 Topic 和无锁队列进行初始化 Constructor using a Topic and a lock-free queue
- Template Parameters
-
| Data | 队列消息的数据类型 Data type stored in the queue message |
- Parameters
-
| name | 订阅的主题名称 Name of the subscribed topic |
| queue | 订阅的消息队列 Subscribed message queue |
| domain | 可选的域指针 Optional domain pointer (default: nullptr) |
Definition at line 342 of file subscriber.hpp.
◆ QueuedSubscriber() [3/5]
template<typename Data >
| LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
Topic | topic, |
|
|
LockFreeQueue< Data > & | queue ) |
|
inline |
构造函数,使用 Topic 和无锁队列进行初始化 Constructor using a Topic and a lock-free queue
- Template Parameters
-
| Data | 队列存储的数据类型 Data type stored in the queue |
- Parameters
-
| topic | 订阅的主题 Subscribed topic |
| queue | 订阅的数据队列 Subscribed data queue |
- Note
- 包含初始化期动态内存分配,订阅者应长期存在。 Contains initialization-time dynamic allocation; subscribers are expected to be long-lived.
Definition at line 360 of file subscriber.hpp.
361 {
363
364 block_ = new LockFreeList::Node<QueueBlock>;
366 block_->data_.queue = &queue;
367 block_->data_.fun = [](MicrosecondTimestamp, RawData data, QueueBlock& block)
368 {
369 LockFreeQueue<Data>* queue = reinterpret_cast<LockFreeQueue<Data>*>(block.queue);
370 (void)queue->Push(*reinterpret_cast<Data*>(data.addr_));
371 };
372
373 topic.block_->data_.subers.Add(*block_);
374 }
@ QUEUE
队列订阅者。Queued subscriber.
static void CheckSubscriberDataSize(Topic topic)
校验订阅者数据类型和主题最大长度是否兼容。 Checks whether subscriber data type is compatible with topic max length.
◆ QueuedSubscriber() [4/5]
构造函数,使用 Topic 和带时间戳消息队列进行初始化 Constructor using a Topic and a timestamped message queue
Definition at line 381 of file subscriber.hpp.
382 {
384
385 block_ = new LockFreeList::Node<QueueBlock>;
387 block_->data_.queue = &queue;
388 block_->data_.fun =
389 [](MicrosecondTimestamp timestamp, RawData data, QueueBlock& block)
390 {
391 LockFreeQueue<Message<Data>>* queue =
392 reinterpret_cast<LockFreeQueue<Message<Data>>*>(block.queue);
393 (void)queue->Push(Message<Data>{timestamp, *reinterpret_cast<Data*>(data.addr_)});
394 };
395
396 topic.block_->data_.subers.Add(*block_);
397 }
◆ QueuedSubscriber() [5/5]
Definition at line 402 of file subscriber.hpp.
402 : block_(other.block_)
403 {
404 other.block_ = nullptr;
405 }
◆ operator=()
Definition at line 407 of file subscriber.hpp.
408 {
409 if (this != &other)
410 {
411 block_ = other.block_;
412 other.block_ = nullptr;
413 }
414 return *this;
415 }
◆ block_
The documentation for this class was generated from the following file: