Apollo 10.0
自动驾驶开放平台
apollo::cyber::transport::ConditionNotifier类 参考

#include <condition_notifier.h>

类 apollo::cyber::transport::ConditionNotifier 继承关系图:
apollo::cyber::transport::ConditionNotifier 的协作图:

Public 成员函数

virtual ~ConditionNotifier ()
 
void Shutdown () override
 
bool Notify (const ReadableInfo &info) override
 
bool Listen (int timeout_ms, ReadableInfo *info) override
 
- Public 成员函数 继承自 apollo::cyber::transport::NotifierBase
virtual ~NotifierBase ()=default
 

静态 Public 成员函数

static const char * Type ()
 

详细描述

在文件 condition_notifier.h33 行定义.

构造及析构函数说明

◆ ~ConditionNotifier()

apollo::cyber::transport::ConditionNotifier::~ConditionNotifier ( )
virtual

在文件 condition_notifier.cc46 行定义.

成员函数说明

◆ Listen()

bool apollo::cyber::transport::ConditionNotifier::Listen ( int  timeout_ms,
ReadableInfo info 
)
overridevirtual

实现了 apollo::cyber::transport::NotifierBase.

在文件 condition_notifier.cc71 行定义.

71 {
72 if (info == nullptr) {
73 AERROR << "info nullptr.";
74 return false;
75 }
76
77 if (is_shutdown_.load()) {
78 ADEBUG << "notifier is shutdown.";
79 return false;
80 }
81
82 int timeout_us = timeout_ms * 1000;
83 while (!is_shutdown_.load()) {
84 uint64_t seq = indicator_->next_seq.load();
85 if (seq != next_seq_) {
86 auto idx = next_seq_ % kBufLength;
87 auto actual_seq = indicator_->seqs[idx];
88 if (actual_seq >= next_seq_) {
89 next_seq_ = actual_seq;
90 *info = indicator_->infos[idx];
91 ++next_seq_;
92 return true;
93 } else {
94 ADEBUG << "seq[" << next_seq_ << "] is writing, can not read now.";
95 }
96 }
97
98 if (timeout_us > 0) {
99 std::this_thread::sleep_for(std::chrono::microseconds(50));
100 timeout_us -= 50;
101 } else {
102 return false;
103 }
104 }
105 return false;
106}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
uint32_t seq
Sequence number of message

◆ Notify()

bool apollo::cyber::transport::ConditionNotifier::Notify ( const ReadableInfo info)
overridevirtual

实现了 apollo::cyber::transport::NotifierBase.

在文件 condition_notifier.cc57 行定义.

57 {
58 if (is_shutdown_.load()) {
59 ADEBUG << "notifier is shutdown.";
60 return false;
61 }
62
63 uint64_t seq = indicator_->next_seq.fetch_add(1);
64 uint64_t idx = seq % kBufLength;
65 indicator_->infos[idx] = info;
66 indicator_->seqs[idx] = seq;
67
68 return true;
69}

◆ Shutdown()

void apollo::cyber::transport::ConditionNotifier::Shutdown ( )
overridevirtual

实现了 apollo::cyber::transport::NotifierBase.

在文件 condition_notifier.cc48 行定义.

48 {
49 if (is_shutdown_.exchange(true)) {
50 return;
51 }
52
53 std::this_thread::sleep_for(std::chrono::milliseconds(100));
54 Reset();
55}

◆ Type()

static const char * apollo::cyber::transport::ConditionNotifier::Type ( )
inlinestatic

在文件 condition_notifier.h47 行定义.

47{ return "condition"; }

该类的文档由以下文件生成: