Skip to content

Commit c267907

Browse files
committed
fix: register a push callback for dynamic subscriptions
`DynamicSubscriptionExecutable` did not implement `register_on_ready`, so it fell through to the trait's no-op default. As a result the event-driven executor never installed a "new message" callback for dynamic subscriptions, and their callbacks never fired -- the executor was never notified that a message had arrived. Implement `register_on_ready` the same way a regular subscription does: a dynamic subscription shares the rcl subscription readiness path, so report `ReadyKind::Basic` and reuse `set_subscription_on_new_message`.
1 parent d0002ce commit c267907

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

rclrs/src/dynamic_message/dynamic_subscription.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,23 @@ impl<Payload: 'static> RclPrimitive for DynamicSubscriptionExecutable<Payload> {
236236
fn handle(&self) -> RclPrimitiveHandle {
237237
RclPrimitiveHandle::Subscription(self.handle.lock())
238238
}
239+
240+
fn register_on_ready(
241+
&self,
242+
on_ready: Box<dyn Fn(ReadyKind, usize) + Send + Sync>,
243+
) -> Result<Option<Box<dyn crate::OnReadyHandle>>, RclrsError> {
244+
// A dynamic subscription shares the rcl subscription readiness path with a
245+
// regular subscription, so report it as `Basic` and reuse the same setter.
246+
// Without this, an event-driven executor never learns the subscription has
247+
// a message and its callback never fires.
248+
let on_ready = move |n| on_ready(ReadyKind::Basic, n);
249+
let registration = crate::executor::event_callback::OnReadyRegistration::new(
250+
Arc::clone(&self.handle),
251+
crate::subscription::set_subscription_on_new_message,
252+
Box::new(on_ready),
253+
)?;
254+
Ok(Some(Box::new(registration)))
255+
}
239256
}
240257

241258
/// Struct for receiving messages whose type is only known at runtime.

0 commit comments

Comments
 (0)