15 #ifndef RCLCPP__EXPERIMENTAL__BUFFERS__RING_BUFFER_IMPLEMENTATION_HPP_ 16 #define RCLCPP__EXPERIMENTAL__BUFFERS__RING_BUFFER_IMPLEMENTATION_HPP_ 35 namespace experimental
40 template<
typename BufferT>
45 : capacity_(capacity),
46 ring_buffer_(capacity),
47 write_index_(capacity_ - 1),
62 write_index_ =
next(write_index_);
63 ring_buffer_[write_index_] =
std::move(request);
66 read_index_ =
next(read_index_);
81 auto request =
std::move(ring_buffer_[read_index_]);
82 read_index_ =
next(read_index_);
89 inline size_t next(
size_t val)
91 return (val + 1) % capacity_;
101 return size_ == capacity_;
122 #endif // RCLCPP__EXPERIMENTAL__BUFFERS__RING_BUFFER_IMPLEMENTATION_HPP_
bool is_full()
Definition: ring_buffer_implementation.hpp:99
Logger get_logger(const std::string &name)
Return a named logger.
Definition: ring_buffer_implementation.hpp:41
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
void clear()
Definition: ring_buffer_implementation.hpp:104
#define RCLCPP_ERROR(logger,...)
Definition: logging.hpp:1418
void enqueue(BufferT request)
Definition: ring_buffer_implementation.hpp:58
BufferT dequeue()
Definition: ring_buffer_implementation.hpp:72
bool has_data() const
Definition: ring_buffer_implementation.hpp:94
size_t next(size_t val)
Definition: ring_buffer_implementation.hpp:89
Definition: buffer_implementation_base.hpp:26
RingBufferImplementation(size_t capacity)
Definition: ring_buffer_implementation.hpp:44
virtual ~RingBufferImplementation()
Definition: ring_buffer_implementation.hpp:56