rclcpp  master
C++ ROS Client Library API
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 <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. More...
 
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 >
 MessageMemoryStrategy ()
 
 MessageMemoryStrategy (std::shared_ptr< std::allocator< void > > allocator)
 
virtual ~MessageMemoryStrategy ()=default
 
virtual std::shared_ptr< rcl_serialized_message_tborrow_serialized_message (size_t capacity)
 
virtual std::shared_ptr< rcl_serialized_message_tborrow_serialized_message ()
 
virtual void set_default_buffer_capacity (size_t capacity)
 
virtual void return_serialized_message (std::shared_ptr< rcl_serialized_message_t > &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 >
using MessageAllocTraits = allocator::AllocRebind< MessageT, std::allocator< void > >
 
using MessageAlloc = typename MessageAllocTraits::allocator_type
 
using MessageDeleter = allocator::Deleter< MessageAlloc, MessageT >
 
using SerializedMessageAllocTraits = allocator::AllocRebind< rcl_serialized_message_t, std::allocator< void > >
 
using SerializedMessageAlloc = typename SerializedMessageAllocTraits::allocator_type
 
using SerializedMessageDeleter = allocator::Deleter< SerializedMessageAlloc, rcl_serialized_message_t >
 
using BufferAllocTraits = allocator::AllocRebind< char, std::allocator< void > >
 
using BufferAlloc = typename BufferAllocTraits::allocator_type
 
using BufferDeleter = allocator::Deleter< BufferAlloc, char >
 
- Static Public Member Functions inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT >
static SharedPtr create_default ()
 Default factory method. More...
 
- Public Attributes inherited from rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT >
std::shared_ptr< MessageAllocmessage_allocator_
 
MessageDeleter message_deleter_
 
std::shared_ptr< SerializedMessageAllocserialized_message_allocator_
 
SerializedMessageDeleter serialized_message_deleter_
 
std::shared_ptr< BufferAllocbuffer_allocator_
 
BufferDeleter buffer_deleter_
 
size_t default_buffer_capacity_
 
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).

Constructor & Destructor Documentation

◆ MessagePoolMemoryStrategy()

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

Default constructor.

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 >.

◆ 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 >.

Member Data Documentation

◆ pool_

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

◆ next_array_index_

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

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