@@ -7,7 +7,7 @@ use crate::{
7
7
rcl_timer_is_canceled, rcl_timer_is_ready, rcl_timer_reset, rcl_timer_t,
8
8
rcutils_get_default_allocator,
9
9
} ,
10
- NodeHandle , RclReturnCode , RclrsError , ToResult , ENTITY_LIFECYCLE_MUTEX ,
10
+ ContextHandle , RclReturnCode , RclrsError , ToResult , ENTITY_LIFECYCLE_MUTEX ,
11
11
} ;
12
12
use std:: {
13
13
i64,
@@ -28,7 +28,7 @@ unsafe impl Send for rcl_timer_t {}
28
28
pub struct TimerHandle {
29
29
rcl_timer : Mutex < rcl_timer_t > ,
30
30
_clock : Clock ,
31
- _node_handle : Arc < NodeHandle > ,
31
+ _context_handle : Arc < ContextHandle > ,
32
32
pub ( crate ) in_use_by_wait_set : Arc < AtomicBool > ,
33
33
}
34
34
@@ -81,7 +81,7 @@ impl Timer {
81
81
/// Creates a new `Timer` with the given period and callback.
82
82
/// Periods greater than i64::MAX nanoseconds will saturate to i64::MAX.
83
83
pub ( crate ) fn new < F > (
84
- node_handle : Arc < NodeHandle > ,
84
+ context_handle : Arc < ContextHandle > ,
85
85
clock : Clock ,
86
86
period : Duration ,
87
87
callback : F ,
@@ -98,8 +98,8 @@ impl Timer {
98
98
let clock_clone = clock. rcl_clock . clone ( ) ;
99
99
let mut rcl_clock = clock_clone. lock ( ) . unwrap ( ) ;
100
100
101
- let node_handle_clone = node_handle . clone ( ) ;
102
- let mut rcl_context = node_handle_clone . context_handle . rcl_context . lock ( ) . unwrap ( ) ;
101
+ let context_handle_clone = context_handle . clone ( ) ;
102
+ let mut rcl_context = context_handle_clone . rcl_context . lock ( ) . unwrap ( ) ;
103
103
104
104
// core::time::Duration will always be >= 0, so no need to check for negatives.
105
105
let period_nanos = i64:: try_from ( period. as_nanos ( ) ) . unwrap_or ( i64:: MAX ) ;
@@ -113,7 +113,7 @@ impl Timer {
113
113
// * The rcl_timer is zero-initialized as mandated by this function.
114
114
// * The rcl_clock is kept alive by the Clock within TimerHandle because it is
115
115
// a dependency of the timer.
116
- // * The rcl_context is kept alive by the NodeHandle within TimerHandle because
116
+ // * The rcl_context is kept alive by the ContextHandle within TimerHandle because
117
117
// it is a dependency of the timer.
118
118
// * The period is copied into this function so it can be dropped afterwards.
119
119
// * The callback is None / nullptr so doesn't need to be kept alive.
@@ -136,7 +136,7 @@ impl Timer {
136
136
handle : TimerHandle {
137
137
rcl_timer : Mutex :: new ( rcl_timer) ,
138
138
_clock : clock,
139
- _node_handle : node_handle ,
139
+ _context_handle : context_handle ,
140
140
in_use_by_wait_set : Arc :: new ( AtomicBool :: new ( false ) ) ,
141
141
} ,
142
142
} )
@@ -304,17 +304,17 @@ impl TimerBase for Timer {
304
304
mod tests {
305
305
use std:: time:: Duration ;
306
306
307
- use crate :: { create_node , Context } ;
307
+ use crate :: { Clock , Context } ;
308
308
309
309
use super :: Timer ;
310
310
311
- // Pass in a new node name each time to avoid logging conflicts.
312
- fn new_timer ( node_name : & str ) -> Timer {
313
- let node = create_node ( & Context :: new ( [ ] ) . unwrap ( ) , node_name ) . unwrap ( ) ;
311
+ fn new_timer ( ) -> Timer {
312
+ let context = Context :: new ( [ ] ) . unwrap ( ) ;
313
+ let clock = Clock :: system ( ) ;
314
314
315
315
let timer = Timer :: new (
316
- node . handle . clone ( ) ,
317
- node . get_clock ( ) ,
316
+ context . handle . clone ( ) ,
317
+ clock ,
318
318
Duration :: from_secs ( 0 ) ,
319
319
|_| { } ,
320
320
) ;
@@ -324,20 +324,20 @@ mod tests {
324
324
325
325
#[ test]
326
326
fn creation ( ) {
327
- let _ = new_timer ( "test_timer_creation" ) ;
327
+ let _ = new_timer ( ) ;
328
328
}
329
329
330
330
#[ test]
331
331
fn is_ready ( ) {
332
- let timer = new_timer ( "test_timer_is_ready" ) ;
332
+ let timer = new_timer ( ) ;
333
333
334
334
// Calling is_ready will trigger the debug_assert check on the rcl return value.
335
335
timer. is_ready ( ) ;
336
336
}
337
337
338
338
#[ test]
339
339
fn time_until_next_call ( ) {
340
- let timer = new_timer ( "test_timer_next_call" ) ;
340
+ let timer = new_timer ( ) ;
341
341
342
342
timer
343
343
. time_until_next_call ( )
@@ -346,15 +346,15 @@ mod tests {
346
346
347
347
#[ test]
348
348
fn time_since_last_call ( ) {
349
- let timer = new_timer ( "test_timer_last_call" ) ;
349
+ let timer = new_timer ( ) ;
350
350
351
351
// Calling time_since_last_call will trigger the debug_assert check on the rcl return value.
352
352
timer. time_since_last_call ( ) ;
353
353
}
354
354
355
355
#[ test]
356
356
fn update_period ( ) {
357
- let timer = new_timer ( "test_timer_update_period" ) ;
357
+ let timer = new_timer ( ) ;
358
358
359
359
let new_period = Duration :: from_millis ( 100 ) ;
360
360
@@ -369,7 +369,7 @@ mod tests {
369
369
370
370
#[ test]
371
371
fn cancel_timer ( ) {
372
- let timer = new_timer ( "test_timer_cancel" ) ;
372
+ let timer = new_timer ( ) ;
373
373
374
374
// Calling is_canceled will trigger the debug_assert check on the rcl return value.
375
375
assert ! ( !timer. is_canceled( ) ) ;
@@ -382,7 +382,7 @@ mod tests {
382
382
383
383
#[ test]
384
384
fn reset_canceled_timer ( ) {
385
- let timer = new_timer ( "test_timer_reset" ) ;
385
+ let timer = new_timer ( ) ;
386
386
timer. cancel ( ) ;
387
387
388
388
// Calling reset will trigger the debug_assert check on the rcl return value.
0 commit comments