ROS 2 rclcpp + rcl - kilted  kilted
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

class  CircularArray
 

Public Member Functions

std::shared_ptr< MessageT > borrow_message ()
 Borrow a message from the message pool. More...
 
void return_message ([[maybe_unused]] 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_message (std::shared_ptr< MessageT > &msg)
 Release ownership of the message, which will deallocate it if it has no more owners. More...
 
virtual void return_serialized_message (std::shared_ptr< rclcpp::SerializedMessage > &serialized_msg)
 

Protected Attributes

std::shared_ptr< std::mutex > pool_mutex_
 
std::shared_ptr< std::array< MessageT *, Size > > pool_
 
std::shared_ptr< CircularArray< Size > > free_list_
 

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 54 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 87 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 ( [[maybe_unused] ] std::shared_ptr< MessageT > &  msg)
inline

Return a message to the message pool.

This does nothing since the message isn't returned to the pool until the user has dropped all references.

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

Definition at line 117 of file message_pool_memory_strategy.hpp.


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