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, >:
rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT >

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)
 

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

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: