libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Topic::QueuedSubscriber Class Reference

构造函数,使用名称和无锁队列进行初始化 Constructor using a name and a lock-free queue More...

#include <message.hpp>

Public Member Functions

template<typename Data , uint32_t Length>
 QueuedSubscriber (const char *name, LockFreeQueue< Data > &queue, Domain *domain=nullptr)
 
template<typename Data >
 QueuedSubscriber (Topic topic, LockFreeQueue< Data > &queue)
 构造函数,使用 Topic 和无锁队列进行初始化 Constructor using a Topic and a lock-free queue
 
template<typename Data >
 QueuedSubscriber (const char *name, LockQueue< Data > &queue, Domain *domain=nullptr)
 构造函数,使用名称和带锁队列进行初始化 Constructor using a name and a locked queue
 
template<typename Data >
 QueuedSubscriber (Topic topic, LockQueue< Data > &queue)
 构造函数,使用 Topic 和带锁队列进行初始化 Constructor using a Topic and a locked queue
 

Detailed Description

构造函数,使用名称和无锁队列进行初始化 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 373 of file message.hpp.

Constructor & Destructor Documentation

◆ 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 377 of file message.hpp.

379 {
380 *this = QueuedSubscriber(WaitTopic(name, UINT32_MAX, domain), queue);
381 }
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
Definition message.hpp:916
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

◆ 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 391 of file message.hpp.

392 {
393 if (topic.block_->data_.check_length)
394 {
395 ASSERT(topic.block_->data_.max_length == sizeof(Data));
396 }
397 else
398 {
399 ASSERT(topic.block_->data_.max_length <= sizeof(Data));
400 }
401
402 auto block = new List::Node<QueueBlock>;
403 block->data_.type = SuberType::QUEUE;
404 block->data_.queue = &queue;
405 block->data_.fun = [](RawData &data, void *arg, bool in_isr)
406 {
407 UNUSED(in_isr);
408 LockFreeQueue<Data> *queue = reinterpret_cast<LockFreeQueue<Data>>(arg);
409 queue->Push(reinterpret_cast<Data>(data.addr_));
410 };
411
412 topic.block_->data_.subers.Add(*block);
413 }
@ 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 424 of file message.hpp.

425 {
426 *this = QueuedSubscriber(WaitTopic(name, UINT32_MAX, domain), queue);
427 }

◆ 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 437 of file message.hpp.

438 {
439 if (topic.block_->data_.check_length)
440 {
441 ASSERT(topic.block_->data_.max_length == sizeof(Data));
442 }
443 else
444 {
445 ASSERT(topic.block_->data_.max_length <= sizeof(Data));
446 }
447
448 auto block = new List::Node<QueueBlock>;
449 block->data_.type = SuberType::QUEUE;
450 block->data_.queue = &queue;
451 block->data_.fun = [](RawData &data, void *arg, bool in_isr)
452 {
453 LockQueue<Data> *queue = reinterpret_cast<LockQueue<Data> *>(arg);
454 queue->PushFromCallback(*reinterpret_cast<const Data *>(data.addr_), in_isr);
455 };
456
457 topic.block_->data_.subers.Add(*block);
458 }

The documentation for this class was generated from the following file: