File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -487,3 +487,24 @@ impl CreateBasicExecutor for Context {
487
487
self . create_executor ( runtime)
488
488
}
489
489
}
490
+
491
+ #[ cfg( test) ]
492
+ mod tests {
493
+ use crate :: * ;
494
+ use std:: time:: { Duration , Instant } ;
495
+
496
+ #[ test]
497
+ fn test_spin_once ( ) {
498
+ let context = Context :: default ( ) ;
499
+ let mut executor = context. create_basic_executor ( ) ;
500
+ let node = executor. create_node ( "spin_once" ) . unwrap ( ) ;
501
+ let subscription = node. create_subscription ( "test" , |msg : crate :: vendor:: example_interfaces:: msg:: Empty | { } ) . unwrap ( ) ;
502
+
503
+ let start = Instant :: now ( ) ;
504
+
505
+ for _ in 0 ..10 {
506
+ println ! ( "Spinning exeuctor: {:?}" , start. elapsed( ) ) ;
507
+ executor. spin ( SpinOptions :: default ( ) . timeout ( Duration :: from_secs ( 1 ) ) ) ;
508
+ }
509
+ }
510
+ }
Original file line number Diff line number Diff line change @@ -114,11 +114,15 @@ impl WaitSet {
114
114
} )
115
115
}
116
116
} ;
117
+
118
+ dbg ! ( timeout_ns) ;
117
119
// SAFETY: The comments in rcl mention "This function cannot operate on the same wait set
118
120
// in multiple threads, and the wait sets may not share content."
119
- // We cannot currently guarantee that the wait sets may not share content, but it is
120
- // mentioned in the doc comment for `add_subscription`.
121
- // Also, the rcl_wait_set is obviously valid.
121
+ // * We guarantee that the wait sets do not share content by funneling
122
+ // the exeuctor of each primitive to one (and only one) WaitSet when
123
+ // the primitive gets constructed. The primitive executors are never
124
+ // allowed to transfer wait sets.
125
+ // * The rcl_wait_set is kept valid by the lifecycle of the WaitSet struct.
122
126
match unsafe { rcl_wait ( & mut self . handle . rcl_wait_set , timeout_ns) } . ok ( ) {
123
127
Ok ( _) => ( ) ,
124
128
Err ( error) => match error {
You can’t perform that action at this time.
0 commit comments