Skip to content

Commit a4c1a97

Browse files
committed
Fix missing documentation in wait.rs.
Signed-off-by: Agustin Alba Chicar <[email protected]>
1 parent 08acef5 commit a4c1a97

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

rclrs/src/wait.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct ReadyEntities {
6464
pub guard_conditions: Vec<Arc<GuardCondition>>,
6565
/// A list of services that have potentially received requests.
6666
pub services: Vec<Arc<dyn ServiceBase>>,
67-
/// TODO
67+
/// A list of timers that are potentially due.
6868
pub timers: Vec<Arc<Timer>>,
6969
}
7070

@@ -321,7 +321,16 @@ impl WaitSet {
321321
Ok(())
322322
}
323323

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
325334
pub fn add_timer(&mut self, timer: Arc<Timer>) -> Result<(), RclrsError> {
326335
let exclusive_timer =
327336
ExclusivityGuard::new(Arc::clone(&timer), Arc::clone(&timer.in_use_by_wait_set))?;
@@ -331,7 +340,7 @@ impl WaitSet {
331340
// Passing in a null pointer for the third argument is explicitly allowed.
332341
rcl_wait_set_add_timer(
333342
&mut self.handle.rcl_wait_set,
334-
&* timer.rcl_timer.lock().unwrap() as *const _,
343+
&*timer.rcl_timer.lock().unwrap() as *const _,
335344
core::ptr::null_mut(),
336345
)
337346
}
@@ -486,7 +495,7 @@ mod tests {
486495
fn timer_in_wait_not_set_readies() -> Result<(), RclrsError> {
487496
let context = Context::new([])?;
488497
let clock = Clock::steady();
489-
let period: i64 = 1e6 as i64; // 1 milliseconds.
498+
let period: i64 = 1e6 as i64; // 1 millisecond.
490499
let timer = Arc::new(Timer::new(&clock, &context, period)?);
491500

492501
let mut wait_set = WaitSet::new(0, 0, 1, 0, 0, 0, &context)?;
@@ -502,7 +511,7 @@ mod tests {
502511
fn timer_in_wait_set_readies() -> Result<(), RclrsError> {
503512
let context = Context::new([])?;
504513
let clock = Clock::steady();
505-
let period: i64 = 1e6 as i64; // 1 milliseconds.
514+
let period: i64 = 1e6 as i64; // 1 millisecond.
506515
let timer = Arc::new(Timer::new(&clock, &context, period)?);
507516

508517
let mut wait_set = WaitSet::new(0, 0, 1, 0, 0, 0, &context)?;

0 commit comments

Comments
 (0)