Skip to content

Commit 41c30bf

Browse files
authored
Merge pull request #5 from alsora/asoragna/entities-ownership
Asoragna/entities ownership
2 parents 5fdf5a2 + ba7e72f commit 41c30bf

File tree

7 files changed

+319
-186
lines changed

7 files changed

+319
-186
lines changed

rclcpp/include/rclcpp/executors/events_executor.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#define RCLCPP__EXECUTORS__EVENTS_EXECUTOR_HPP_
1717

1818
#include <chrono>
19-
#include <deque>
2019
#include <memory>
20+
#include <queue>
2121
#include <vector>
2222

2323
#include "rclcpp/executor.hpp"
@@ -174,9 +174,7 @@ class EventsExecutor : public rclcpp::Executor
174174
private:
175175
RCLCPP_DISABLE_COPY(EventsExecutor)
176176

177-
// Event queue implementation is a deque only to
178-
// facilitate the removal of events from expired entities.
179-
using EventQueue = std::deque<rmw_listener_event_t>;
177+
using EventQueue = std::queue<rmw_listener_event_t>;
180178

181179
// Executor callback: Push new events into the queue and trigger cv.
182180
// This function is called by the DDS entities when an event happened,
@@ -192,7 +190,7 @@ class EventsExecutor : public rclcpp::Executor
192190
{
193191
std::unique_lock<std::mutex> lock(this_executor->push_mutex_);
194192

195-
this_executor->event_queue_.push_back(event);
193+
this_executor->event_queue_.push(event);
196194
}
197195
// Notify that the event queue has some events in it.
198196
this_executor->event_queue_cv_.notify_one();
@@ -208,12 +206,12 @@ class EventsExecutor : public rclcpp::Executor
208206
void
209207
execute_event(const rmw_listener_event_t & event);
210208

211-
// We use two instances of EventQueue to allow threads to push events while we execute them
209+
// Queue where entities can push events
212210
EventQueue event_queue_;
213-
EventQueue execution_event_queue_;
214211

215212
EventsExecutorEntitiesCollector::SharedPtr entities_collector_;
216213
EventsExecutorNotifyWaitable::SharedPtr executor_notifier_;
214+
217215
// Mutex to protect the insertion of events in the queue
218216
std::mutex push_mutex_;
219217
// Variable used to notify when an event is added to the queue

rclcpp/include/rclcpp/executors/events_executor_entities_collector.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <list>
1919
#include <map>
2020
#include <memory>
21+
#include <unordered_map>
2122
#include <vector>
2223

2324
#include "rclcpp/executors/event_waitable.hpp"

0 commit comments

Comments
 (0)