构造函数,使用名称和无锁队列进行初始化 Constructor using a name and a lock-free queue
More...
#include <message.hpp>
构造函数,使用名称和无锁队列进行初始化 Constructor using a name and a lock-free queue
- Template Parameters
-
Data | 队列存储的数据类型 Data type stored in the queue |
Length | 队列长度 Queue length |
- Parameters
-
name | 订阅的主题名称 Name of the subscribed topic |
queue | 订阅的数据队列 Subscribed data queue |
domain | 可选的域指针 Optional domain pointer (default: nullptr) |
Definition at line 408 of file message.hpp.
◆ QueuedSubscriber() [1/2]
template<typename Data , uint32_t Length>
LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
const char * | name, |
|
|
LockFreeQueue< Data > & | queue, |
|
|
Domain * | domain = nullptr ) |
|
inline |
Definition at line 412 of file message.hpp.
414 {
415 *
this = QueuedSubscriber(
WaitTopic(name, UINT32_MAX, domain), queue);
416 }
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
◆ QueuedSubscriber() [2/2]
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 |
Definition at line 426 of file message.hpp.
427 {
428 if (topic.block_->data_.check_length)
429 {
430 ASSERT(topic.block_->data_.max_length == sizeof(Data));
431 }
432 else
433 {
434 ASSERT(topic.block_->data_.max_length <= sizeof(Data));
435 }
436
437 auto block = new LockFreeList::Node<QueueBlock>;
439 block->data_.queue = &queue;
440 block->data_.fun = [](RawData &data, void *arg, bool in_isr)
441 {
442 UNUSED(in_isr);
443 LockFreeQueue<Data>* queue = reinterpret_cast<LockFreeQueue<Data>*>(arg);
444 queue->Push(*reinterpret_cast<Data*>(data.addr_));
445 };
446
447 topic.block_->data_.subers.Add(*block);
448 }
@ QUEUE
队列订阅者。Queued subscriber.
The documentation for this class was generated from the following file: