@@ -118,14 +118,25 @@ class SubscriptionIntraProcess : public SubscriptionIntraProcessBase
118118 provide_intra_process_message (ConstMessageSharedPtr message)
119119 {
120120 buffer_->add_shared (std::move (message));
121- trigger_guard_condition ();
121+ std::lock_guard<std::mutex> lock (executor_callback_mutex_);
122+ if (executor_callback_) {
123+ executor_callback_ (executor_, {this , WAITABLE_EVENT});
124+ } else {
125+ trigger_guard_condition ();
126+ }
122127 }
123128
124129 void
125130 provide_intra_process_message (MessageUniquePtr message)
126131 {
127132 buffer_->add_unique (std::move (message));
128- trigger_guard_condition ();
133+
134+ std::lock_guard<std::mutex> lock (executor_callback_mutex_);
135+ if (executor_callback_) {
136+ executor_callback_ (executor_, {this , WAITABLE_EVENT});
137+ } else {
138+ trigger_guard_condition ();
139+ }
129140 }
130141
131142 bool
@@ -134,6 +145,18 @@ class SubscriptionIntraProcess : public SubscriptionIntraProcessBase
134145 return buffer_->use_take_shared_method ();
135146 }
136147
148+ void
149+ set_events_executor_callback (
150+ const rclcpp::executors::EventsExecutor * executor,
151+ rmw_listener_cb_t executor_callback) override
152+ {
153+ std::lock_guard<std::mutex> lock (executor_callback_mutex_);
154+ executor_ = executor;
155+ executor_callback_ = executor_callback;
156+ // Buffer must be cleared under the executor callback lock to make sure that other threads wait for this
157+ buffer_->clear ();
158+ }
159+
137160private:
138161 void
139162 trigger_guard_condition ()
0 commit comments