Skip to content

Commit 896b829

Browse files
committed
Examine timeout crash
Signed-off-by: Michael X. Grey <[email protected]>
1 parent e61d81b commit 896b829

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

rclrs/src/executor.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,24 @@ impl CreateBasicExecutor for Context {
487487
self.create_executor(runtime)
488488
}
489489
}
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+
}

rclrs/src/wait_set.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@ impl WaitSet {
114114
})
115115
}
116116
};
117+
118+
dbg!(timeout_ns);
117119
// SAFETY: The comments in rcl mention "This function cannot operate on the same wait set
118120
// 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.
122126
match unsafe { rcl_wait(&mut self.handle.rcl_wait_set, timeout_ns) }.ok() {
123127
Ok(_) => (),
124128
Err(error) => match error {

0 commit comments

Comments
 (0)