@@ -31,7 +31,7 @@ unsafe impl Send for rcl_subscription_t {}
3131/// [1]: <https://doc.rust-lang.org/reference/destructors.html>
3232pub struct SubscriptionHandle {
3333 rcl_subscription : Mutex < rcl_subscription_t > ,
34- node_handle : Arc < Node > ,
34+ node_handle : Arc < NodeHandle > ,
3535 pub ( crate ) in_use_by_wait_set : Arc < AtomicBool > ,
3636}
3737
8686 pub callback : Mutex < AnySubscriptionCallback < T > > ,
8787 /// Ensure the parent node remains alive as long as the subscription is held.
8888 /// This implementation will change in the future.
89+ #[ allow( unused) ]
8990 node : Arc < Node > ,
9091 message : PhantomData < T > ,
9192}
@@ -142,7 +143,7 @@ where
142143
143144 let handle = Arc :: new ( SubscriptionHandle {
144145 rcl_subscription : Mutex :: new ( rcl_subscription) ,
145- node_handle,
146+ node_handle : Arc :: clone ( & node . handle ) ,
146147 in_use_by_wait_set : Arc :: new ( AtomicBool :: new ( false ) ) ,
147148 } ) ;
148149
@@ -403,24 +404,25 @@ mod tests {
403404
404405 #[ test]
405406 fn test_node_subscription_raii ( ) {
406- use rclrs :: * ;
407+ use crate :: * ;
407408 use std:: sync:: atomic:: Ordering ;
408409
409- let executor = Context :: default ( ) . create_basic_executor ( ) ;
410+ let mut executor = Context :: default ( ) . create_basic_executor ( ) ;
410411
411412 let triggered = Arc :: new ( AtomicBool :: new ( false ) ) ;
412- let callback = |_| {
413- triggered. store ( true , Ordering :: AcqRel ) ;
413+ let inner_triggered = Arc :: clone ( & triggered) ;
414+ let callback = move |_: msg:: Empty | {
415+ inner_triggered. store ( true , Ordering :: Release ) ;
414416 } ;
415417
416- let ( subscription , publisher) = {
418+ let ( _subscription , publisher) = {
417419 let node = executor
418420 . create_node ( & format ! ( "test_node_subscription_raii_{}" , line!( ) ) )
419421 . unwrap ( ) ;
420422
421423 let qos = QoSProfile :: default ( ) . keep_all ( ) . reliable ( ) ;
422424 let subscription = node
423- . create_subscription :: < msg:: Empty > ( "test_topic" , qos, callback)
425+ . create_subscription :: < msg:: Empty , _ > ( "test_topic" , qos, callback)
424426 . unwrap ( ) ;
425427 let publisher = node
426428 . create_publisher :: < msg:: Empty > ( "test_topic" , qos)
@@ -429,9 +431,9 @@ mod tests {
429431 ( subscription, publisher)
430432 } ;
431433
432- publisher. publish ( msg:: Empty { } ) ;
434+ publisher. publish ( msg:: Empty :: default ( ) ) . unwrap ( ) ;
433435 let start_time = std:: time:: Instant :: now ( ) ;
434- while !triggered. load ( Ordering :: AcqRel ) {
436+ while !triggered. load ( Ordering :: Acquire ) {
435437 assert ! ( executor. spin( SpinOptions :: spin_once( ) ) . is_empty( ) ) ;
436438 assert ! ( start_time. elapsed( ) < std:: time:: Duration :: from_secs( 10 ) ) ;
437439 }
0 commit comments