构造函数,使用名称和无锁队列进行初始化 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 390 of file message.hpp.
◆ QueuedSubscriber() [1/4]
template<typename Data , uint32_t Length>
LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
const char * | name, |
|
|
LockFreeQueue< Data > & | queue, |
|
|
Domain * | domain = nullptr ) |
|
inline |
Definition at line 394 of file message.hpp.
396 {
397 *
this = QueuedSubscriber(
WaitTopic(name, UINT32_MAX, domain), queue);
398 }
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/4]
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 408 of file message.hpp.
409 {
410 if (topic.block_->data_.check_length)
411 {
412 ASSERT(topic.block_->data_.max_length == sizeof(Data));
413 }
414 else
415 {
416 ASSERT(topic.block_->data_.max_length <= sizeof(Data));
417 }
418
419 auto block = new LockFreeList::Node<QueueBlock>;
421 block->data_.queue = &queue;
422 block->data_.fun = [](RawData &data, void *arg, bool in_isr)
423 {
424 UNUSED(in_isr);
425 LockFreeQueue<Data> *queue = reinterpret_cast<LockFreeQueue<Data>>(arg);
426 queue->Push(reinterpret_cast<Data>(data.addr_));
427 };
428
429 topic.block_->data_.subers.Add(*block);
430 }
@ QUEUE
队列订阅者。Queued subscriber.
◆ QueuedSubscriber() [3/4]
template<typename Data >
LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
const char * | name, |
|
|
LockQueue< Data > & | queue, |
|
|
Domain * | domain = nullptr ) |
|
inline |
构造函数,使用名称和带锁队列进行初始化 Constructor using a name and a locked queue
- 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) |
Definition at line 441 of file message.hpp.
442 {
443 *
this = QueuedSubscriber(
WaitTopic(name, UINT32_MAX, domain), queue);
444 }
◆ QueuedSubscriber() [4/4]
template<typename Data >
LibXR::Topic::QueuedSubscriber::QueuedSubscriber |
( |
Topic | topic, |
|
|
LockQueue< Data > & | queue ) |
|
inline |
构造函数,使用 Topic 和带锁队列进行初始化 Constructor using a Topic and a locked queue
- Template Parameters
-
Data | 队列存储的数据类型 Data type stored in the queue |
- Parameters
-
topic | 订阅的主题 Subscribed topic |
queue | 订阅的数据队列 Subscribed data queue |
Definition at line 454 of file message.hpp.
455 {
456 if (topic.block_->data_.check_length)
457 {
458 ASSERT(topic.block_->data_.max_length == sizeof(Data));
459 }
460 else
461 {
462 ASSERT(topic.block_->data_.max_length <= sizeof(Data));
463 }
464
465 auto block = new LockFreeList::Node<QueueBlock>;
467 block->data_.queue = &queue;
468 block->data_.fun = [](RawData &data, void *arg, bool in_isr)
469 {
470 LockQueue<Data> *queue = reinterpret_cast<LockQueue<Data> *>(arg);
471 queue->PushFromCallback(*reinterpret_cast<const Data *>(data.addr_), in_isr);
472 };
473
474 topic.block_->data_.subers.Add(*block);
475 }
The documentation for this class was generated from the following file: