ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
Classes | Public Member Functions | Protected Attributes | List of all members
rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, > Class Template Reference

Completely static memory allocation strategy for messages. More...

#include <rclcpp/strategies/message_pool_memory_strategy.hpp>

Inheritance diagram for rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >:
Collaboration graph
[legend]

Classes

struct  PoolMember
 

Public Member Functions

 MessagePoolMemoryStrategy ()
 Default constructor.
 
std::shared_ptr< MessageT > borrow_message ()
 Borrow a message from the message pool. More...
 
void return_message (std::shared_ptr< MessageT > &msg)
 Return a message to the message pool. More...
 
- Public Member Functions inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >
 MessageMemoryStrategy (std::shared_ptr< Alloc > allocator)
 
virtual std::shared_ptr< rclcpp::SerializedMessageborrow_serialized_message (size_t capacity)
 
virtual std::shared_ptr< rclcpp::SerializedMessageborrow_serialized_message ()
 
virtual void set_default_buffer_capacity (size_t capacity)
 
virtual void return_serialized_message (std::shared_ptr< rclcpp::SerializedMessage > &serialized_msg)
 

Protected Attributes

std::array< PoolMember, Size > pool_
 
size_t next_array_index_
 

Additional Inherited Members

- Public Types inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >
using MessageAllocTraits = allocator::AllocRebind< MessageT, Alloc >
 
using MessageAlloc = typename MessageAllocTraits::allocator_type
 
using MessageDeleter = allocator::Deleter< MessageAlloc, MessageT >
 
using SerializedMessageAllocTraits = allocator::AllocRebind< rclcpp::SerializedMessage, Alloc >
 
using SerializedMessageAlloc = typename SerializedMessageAllocTraits::allocator_type
 
using SerializedMessageDeleter = allocator::Deleter< SerializedMessageAlloc, rclcpp::SerializedMessage >
 
using BufferAllocTraits = allocator::AllocRebind< char, Alloc >
 
using BufferAlloc = typename BufferAllocTraits::allocator_type
 
using BufferDeleter = allocator::Deleter< BufferAlloc, char >
 
- Static Public Member Functions inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >
static SharedPtr create_default ()
 Default factory method.
 
- Public Attributes inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >
std::shared_ptr< MessageAlloc > message_allocator_
 
MessageDeleter message_deleter_
 
std::shared_ptr< SerializedMessageAlloc > serialized_message_allocator_
 
SerializedMessageDeleter serialized_message_deleter_
 
std::shared_ptr< BufferAlloc > buffer_allocator_
 
BufferDeleter buffer_deleter_
 
size_t default_buffer_capacity_ = 0
 
rcutils_allocator_t rcutils_allocator_
 

Detailed Description

template<typename MessageT, size_t Size, typename std::enable_if< rosidl_generator_traits::has_fixed_size< MessageT >::value >::type * = nullptr>
class rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >

Completely static memory allocation strategy for messages.

Templated on the type of message pooled by this class and the size of the message pool. Templating allows the program to determine the memory required for this object at compile time. The size of the message pool should be at least the largest number of concurrent accesses to the subscription (usually the number of threads).

Definition at line 47 of file message_pool_memory_strategy.hpp.

Member Function Documentation

◆ borrow_message()

template<typename MessageT , size_t Size, typename std::enable_if< rosidl_generator_traits::has_fixed_size< MessageT >::value >::type * = nullptr>
std::shared_ptr<MessageT> rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >::borrow_message ( )
inlinevirtual

Borrow a message from the message pool.

Manage the message pool ring buffer. Throw an exception if the next message was not available.

Returns
Shared pointer to the borrowed message.

Reimplemented from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >.

Definition at line 69 of file message_pool_memory_strategy.hpp.

◆ return_message()

template<typename MessageT , size_t Size, typename std::enable_if< rosidl_generator_traits::has_fixed_size< MessageT >::value >::type * = nullptr>
void rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >::return_message ( std::shared_ptr< MessageT > &  msg)
inlinevirtual

Return a message to the message pool.

Manage metadata in the message pool ring buffer to release the message.

Parameters
[in]msgShared pointer to the message to return.

Reimplemented from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >.

Definition at line 88 of file message_pool_memory_strategy.hpp.


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