15 #ifndef RCLCPP__EXPERIMENTAL__EXECUTORS__EVENTS_EXECUTOR__SIMPLE_EVENTS_QUEUE_HPP_
16 #define RCLCPP__EXPERIMENTAL__EXECUTORS__EVENTS_EXECUTOR__SIMPLE_EVENTS_QUEUE_HPP_
18 #include <condition_variable>
23 #include "rclcpp/experimental/executors/events_executor/events_queue.hpp"
27 namespace experimental
54 single_event.num_events = 1;
56 std::unique_lock<std::mutex> lock(mutex_);
57 for (
size_t ev = 0; ev <
event.num_events; ev++) {
58 event_queue_.push(single_event);
61 events_queue_cv_.notify_one();
73 std::chrono::nanoseconds timeout = std::chrono::nanoseconds::max())
override
75 std::unique_lock<std::mutex> lock(mutex_);
79 if (timeout != std::chrono::nanoseconds::max()) {
81 events_queue_cv_.wait_for(lock, timeout, [
this]() {
return !event_queue_.empty();});
83 events_queue_cv_.wait(lock, [
this]() {
return !event_queue_.empty();});
87 event = event_queue_.front();
104 std::unique_lock<std::mutex> lock(mutex_);
105 return event_queue_.empty();
117 std::unique_lock<std::mutex> lock(mutex_);
118 return event_queue_.size();
123 std::queue<rclcpp::experimental::executors::ExecutorEvent> event_queue_;
125 mutable std::mutex mutex_;
127 std::condition_variable events_queue_cv_;
This abstract class can be used to implement different types of queues where ExecutorEvent can be sto...
This class implements an EventsQueue as a simple wrapper around a std::queue. It does not perform any...
RCLCPP_PUBLIC bool empty() const override
Test whether queue is empty Thread safe.
RCLCPP_PUBLIC bool dequeue(rclcpp::experimental::executors::ExecutorEvent &event, std::chrono::nanoseconds timeout=std::chrono::nanoseconds::max()) override
waits for an event until timeout, gets a single event Thread safe
RCLCPP_PUBLIC void enqueue(const rclcpp::experimental::executors::ExecutorEvent &event) override
enqueue event into the queue Thread safe
RCLCPP_PUBLIC size_t size() const override
Returns the number of elements in the queue. Thread safe.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.