File tree Expand file tree Collapse file tree 1 file changed +35
-10
lines changed Expand file tree Collapse file tree 1 file changed +35
-10
lines changed Original file line number Diff line number Diff line change @@ -227,16 +227,41 @@ impl<Scope: WorkScope> TimerState<Scope> {
227
227
let allocator = rcutils_get_default_allocator ( ) ;
228
228
229
229
let _lifecycle = ENTITY_LIFECYCLE_MUTEX . lock ( ) . unwrap ( ) ;
230
- // SAFETY: We lock the lifecycle mutex since rcl_timer_init is not
231
- // thread-safe.
232
- rcl_timer_init (
233
- & mut * rcl_timer. lock ( ) . unwrap ( ) ,
234
- & mut * rcl_clock,
235
- & mut * rcl_context,
236
- period,
237
- rcl_timer_callback,
238
- allocator,
239
- )
230
+
231
+ // The API for initializing timers changed with the kilted releaase.
232
+ #[ cfg( any( ros_distro = "humble" , ros_distro = "jazzy" ) ) ]
233
+ {
234
+ // SAFETY: We lock the lifecycle mutex since rcl_timer_init is not
235
+ // thread-safe.
236
+ rcl_timer_init (
237
+ & mut * rcl_timer. lock ( ) . unwrap ( ) ,
238
+ & mut * rcl_clock,
239
+ & mut * rcl_context,
240
+ period,
241
+ rcl_timer_callback,
242
+ allocator,
243
+ )
244
+ }
245
+
246
+ // The API for initializing timers changed with the kilted releaase.
247
+ // This new API allows you to opt out of automatically starting the
248
+ // timer as soon as it is created. We could consider exposing this
249
+ // capability to the user, but for now we are just telling it to
250
+ // immediately start the timer.
251
+ #[ cfg( not( any( ros_distro = "humble" , ros_distro = "jazzy" ) ) ) ]
252
+ {
253
+ // SAFETY: We lock the lifecycle mutex since rcl_timer_init is not
254
+ // thread-safe.
255
+ rcl_timer_init (
256
+ & mut * rcl_timer. lock ( ) . unwrap ( ) ,
257
+ & mut * rcl_clock,
258
+ & mut * rcl_context,
259
+ period,
260
+ rcl_timer_callback,
261
+ allocator,
262
+ true ,
263
+ )
264
+ }
240
265
}
241
266
. ok ( ) ?;
242
267
You can’t perform that action at this time.
0 commit comments