Class MessageCacheInterface
Defined in File message_cache_interface.hpp
Inheritance Relationships
Derived Types
public rosbag2_cpp::cache::CircularMessageCache
(Class CircularMessageCache)public rosbag2_cpp::cache::MessageCache
(Class MessageCache)
Class Documentation
-
class MessageCacheInterface
This class provides the interface for all MessageCache implementations. The interface is designed around double buffered MessageCache implementations due to the inherent performance benefit that they provide.
Any class that implements the MessageCacheInterface should make use of a class derived from the CacheBufferInterface as its buffer(s). Any synchronization that is required to manage more than one CacheBuffer should be handled in the class that implements this interface.
Subclassed by rosbag2_cpp::cache::CircularMessageCache, rosbag2_cpp::cache::MessageCache
Public Functions
-
inline virtual ~MessageCacheInterface()
Push a bag message into the producer buffer.
-
virtual std::shared_ptr<CacheBufferInterface> get_consumer_buffer() = 0
Get a pointer to the buffer that can be used for consuming the cached messages. This call locks access to the buffer,
swap_buffers
andget_consumer_buffer
will block untilrelease_consumer_buffer
is called to unlock access to the buffer. Consumer should callrelease_consumer_buffer
when they are done consuming the messages.- Returns:
a pointer to the consumer buffer interface.
-
virtual void release_consumer_buffer() = 0
Signals that tne consumer is done consuming, unlocking the buffer so it may be swapped.
-
inline virtual void wait_for_data()
Blocks current thread and going to wait until notify_data_ready will be called.
-
virtual void swap_buffers() = 0
Swap producer and consumer buffers. Note: this will block if
get_consumer_buffer
has been called butrelease_consumer_buffer
has not been called yet to signal end of consuming.
-
inline virtual void begin_flushing()
Go into a read-only state to drain the final consumer buffer without letting in new data.
-
inline virtual void done_flushing()
Call after
begin_flushing
, once the final consumer buffer is emptied.
-
inline virtual void log_dropped()
Print a log message with details of any dropped messages.
-
inline virtual void notify_data_ready()
Producer API: notify wait_for_data() to wake up and unblock consumer thread.
-
inline virtual ~MessageCacheInterface()