17 #ifndef CYBER_TRANSPORT_MESSAGE_HISTORY_H_ 18 #define CYBER_TRANSPORT_MESSAGE_HISTORY_H_ 34 template <
typename MessageT>
57 uint32_t
depth()
const {
return depth_; }
64 std::list<CachedMessage> msgs_;
65 mutable std::mutex msgs_mutex_;
68 template <
typename MessageT>
70 : enabled_(false), max_depth_(1000) {
72 if (global_conf.has_transport_conf() &&
73 global_conf.transport_conf().has_resource_limit()) {
75 global_conf.transport_conf().resource_limit().max_history_depth();
78 if (attr.
history_policy == proto::QosHistoryPolicy::HISTORY_KEEP_ALL) {
82 if (depth_ > max_depth_) {
88 template <
typename MessageT>
93 template <
typename MessageT>
99 std::lock_guard<std::mutex> lock(msgs_mutex_);
100 msgs_.emplace_back(msg, msg_info);
101 while (msgs_.size() > depth_) {
106 template <
typename MessageT>
108 std::lock_guard<std::mutex> lock(msgs_mutex_);
112 template <
typename MessageT>
114 std::vector<CachedMessage>* msgs)
const {
115 if (msgs ==
nullptr) {
119 std::lock_guard<std::mutex> lock(msgs_mutex_);
120 msgs->reserve(msgs_.size());
121 msgs->insert(msgs->begin(), msgs_.begin(), msgs_.end());
124 template <
typename MessageT>
126 std::lock_guard<std::mutex> lock(msgs_mutex_);
134 #endif // CYBER_TRANSPORT_MESSAGE_HISTORY_H_ uint32_t max_depth() const
Definition: history.h:58
CachedMessage(const MessagePtr &message, const MessageInfo &message_info)
Definition: history.h:39
Definition: history_attributes.h:28
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
size_t GetSize() const
Definition: history.h:125
void GetCachedMessage(std::vector< CachedMessage > *msgs) const
Definition: history.h:113
void Enable()
Definition: history.h:49
void Disable()
Definition: history.h:50
proto::QosHistoryPolicy history_policy
Definition: history_attributes.h:36
History(const HistoryAttributes &attr)
Definition: history.h:69
uint32_t depth
Definition: history_attributes.h:37
virtual ~History()
Definition: history.h:89
Definition: message_info.h:30
uint32_t depth() const
Definition: history.h:57
std::shared_ptr< MessageT > MessagePtr
Definition: history.h:37
MessagePtr msg
Definition: history.h:42
void Clear()
Definition: history.h:107
MessageInfo msg_info
Definition: history.h:43
void Add(const MessagePtr &msg, const MessageInfo &msg_info)
Definition: history.h:94