rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_
16 #define RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_
20 #include "rosidl_runtime_cpp/traits.hpp"
30 namespace message_pool_memory_strategy
44 rosidl_generator_traits::has_fixed_size<MessageT>::value
57 for (
size_t i = 0; i < Size; ++i) {
58 pool_[i].msg_ptr_ = std::make_shared<MessageT>();
59 pool_[i].used =
false;
73 if (
pool_[current_index].used) {
76 pool_[current_index].msg_ptr_->~MessageT();
77 new (
pool_[current_index].msg_ptr_.get())MessageT;
79 pool_[current_index].used =
true;
80 return pool_[current_index].msg_ptr_;
90 for (
size_t i = 0; i < Size; ++i) {
91 if (
pool_[i].msg_ptr_ == msg) {
92 pool_[i].used =
false;
114 #endif // RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_
bool used
Definition: message_pool_memory_strategy.hpp:103
Definition: message_pool_memory_strategy.hpp:100
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
size_t next_array_index_
Definition: message_pool_memory_strategy.hpp:107
std::shared_ptr< MessageT > borrow_message()
Borrow a message from the message pool.
Definition: message_pool_memory_strategy.hpp:69
std::shared_ptr< MessageT > msg_ptr_
Definition: message_pool_memory_strategy.hpp:102
Completely static memory allocation strategy for messages.
Definition: message_pool_memory_strategy.hpp:47
Default allocation strategy for messages received by subscriptions.
Definition: message_memory_strategy.hpp:41
void return_message(std::shared_ptr< MessageT > &msg)
Return a message to the message pool.
Definition: message_pool_memory_strategy.hpp:88
std::array< PoolMember, Size > pool_
Definition: message_pool_memory_strategy.hpp:106