@@ -64,7 +64,7 @@ pub struct ReadyEntities {
64
64
pub guard_conditions : Vec < Arc < GuardCondition > > ,
65
65
/// A list of services that have potentially received requests.
66
66
pub services : Vec < Arc < dyn ServiceBase > > ,
67
- /// TODO
67
+ /// A list of timers that are potentially due.
68
68
pub timers : Vec < Arc < Timer > > ,
69
69
}
70
70
@@ -321,7 +321,16 @@ impl WaitSet {
321
321
Ok ( ( ) )
322
322
}
323
323
324
- /// TBD
324
+ /// Adds a timer to the wait set.
325
+ ///
326
+ /// # Errors
327
+ /// - If the timer was already added to this wait set or another one,
328
+ /// [`AlreadyAddedToWaitSet`][1] will be returned
329
+ /// - If the number of timer in the wait set is larger than the
330
+ /// capacity set in [`WaitSet::new`], [`WaitSetFull`][2] will be returned
331
+ ///
332
+ /// [1]: crate::RclrsError
333
+ /// [2]: crate::RclReturnCode
325
334
pub fn add_timer ( & mut self , timer : Arc < Timer > ) -> Result < ( ) , RclrsError > {
326
335
let exclusive_timer =
327
336
ExclusivityGuard :: new ( Arc :: clone ( & timer) , Arc :: clone ( & timer. in_use_by_wait_set ) ) ?;
@@ -331,7 +340,7 @@ impl WaitSet {
331
340
// Passing in a null pointer for the third argument is explicitly allowed.
332
341
rcl_wait_set_add_timer (
333
342
& mut self . handle . rcl_wait_set ,
334
- & * timer. rcl_timer . lock ( ) . unwrap ( ) as * const _ ,
343
+ & * timer. rcl_timer . lock ( ) . unwrap ( ) as * const _ ,
335
344
core:: ptr:: null_mut ( ) ,
336
345
)
337
346
}
@@ -486,7 +495,7 @@ mod tests {
486
495
fn timer_in_wait_not_set_readies ( ) -> Result < ( ) , RclrsError > {
487
496
let context = Context :: new ( [ ] ) ?;
488
497
let clock = Clock :: steady ( ) ;
489
- let period: i64 = 1e6 as i64 ; // 1 milliseconds .
498
+ let period: i64 = 1e6 as i64 ; // 1 millisecond .
490
499
let timer = Arc :: new ( Timer :: new ( & clock, & context, period) ?) ;
491
500
492
501
let mut wait_set = WaitSet :: new ( 0 , 0 , 1 , 0 , 0 , 0 , & context) ?;
@@ -502,7 +511,7 @@ mod tests {
502
511
fn timer_in_wait_set_readies ( ) -> Result < ( ) , RclrsError > {
503
512
let context = Context :: new ( [ ] ) ?;
504
513
let clock = Clock :: steady ( ) ;
505
- let period: i64 = 1e6 as i64 ; // 1 milliseconds .
514
+ let period: i64 = 1e6 as i64 ; // 1 millisecond .
506
515
let timer = Arc :: new ( Timer :: new ( & clock, & context, period) ?) ;
507
516
508
517
let mut wait_set = WaitSet :: new ( 0 , 0 , 1 , 0 , 0 , 0 , & context) ?;
0 commit comments