Skip to content

Commit ca78af8

Browse files
committed
Refine rcl_clock_t API thread-safety documentation.
Signed-off-by: Michel Hidalgo <[email protected]>
1 parent 03d4a76 commit ca78af8

1 file changed

Lines changed: 59 additions & 18 deletions

File tree

rcl/include/rcl/time.h

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ rcl_clock_valid(rcl_clock_t * clock);
173173
* Attribute | Adherence
174174
* ------------------ | -------------
175175
* Allocates Memory | Yes [1]
176-
* Thread-Safe | No
176+
* Thread-Safe | No [2]
177177
* Uses Atomics | No
178178
* Lock-Free | Yes
179179
*
180180
* <i>[1] If `clock_type` is `RCL_ROS_TIME`</i>
181+
* <i>[2] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
182+
* Thread-safety is also affected by that of the `allocator` object.</i>
181183
*
182184
* \param[in] clock_type the type identifying the time source to provide
183185
* \param[in] clock the handle to the clock which is being initialized
@@ -208,10 +210,14 @@ rcl_clock_init(
208210
* Attribute | Adherence
209211
* ------------------ | -------------
210212
* Allocates Memory | No
211-
* Thread-Safe | No
213+
* Thread-Safe | No [1]
212214
* Uses Atomics | No
213215
* Lock-Free | Yes
214216
*
217+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
218+
* Thread-safety is also affected by that of the `allocator` object associated with the
219+
* `clock` object.</i>
220+
*
215221
* \param[in] clock the handle to the clock which is being finalized
216222
* \return `RCL_RET_OK` if the time source was successfully finalized, or
217223
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
@@ -232,10 +238,13 @@ rcl_clock_fini(
232238
* Attribute | Adherence
233239
* ------------------ | -------------
234240
* Allocates Memory | Yes
235-
* Thread-Safe | No
241+
* Thread-Safe | No [1]
236242
* Uses Atomics | No
237243
* Lock-Free | Yes
238244
*
245+
* <i>[2] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
246+
* Thread-safety is also affected by that of the `allocator` object.</i>
247+
*
239248
* \param[in] clock the handle to the clock which is being initialized
240249
* \param[in] allocator The allocator to use for allocations
241250
* \return `RCL_RET_OK` if the time source was successfully initialized, or
@@ -262,10 +271,14 @@ rcl_ros_clock_init(
262271
* Attribute | Adherence
263272
* ------------------ | -------------
264273
* Allocates Memory | No
265-
* Thread-Safe | No
274+
* Thread-Safe | No [1]
266275
* Uses Atomics | No
267276
* Lock-Free | Yes
268277
*
278+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
279+
* Thread-safety is also affected by that of the `allocator` object associated with the
280+
* `clock` object.</i>
281+
*
269282
* \param[in] clock the handle to the clock which is being initialized
270283
* \return `RCL_RET_OK` if the time source was successfully finalized, or
271284
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
@@ -286,10 +299,13 @@ rcl_ros_clock_fini(
286299
* Attribute | Adherence
287300
* ------------------ | -------------
288301
* Allocates Memory | No
289-
* Thread-Safe | No
302+
* Thread-Safe | No [1]
290303
* Uses Atomics | No
291304
* Lock-Free | Yes
292305
*
306+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
307+
* Thread-safety is also affected by that of the `allocator` object.</i>
308+
*
293309
* \param[in] clock the handle to the clock which is being initialized
294310
* \param[in] allocator The allocator to use for allocations
295311
* \return `RCL_RET_OK` if the time source was successfully initialized, or
@@ -318,10 +334,14 @@ rcl_steady_clock_init(
318334
* Attribute | Adherence
319335
* ------------------ | -------------
320336
* Allocates Memory | No
321-
* Thread-Safe | No
337+
* Thread-Safe | No [1]
322338
* Uses Atomics | No
323339
* Lock-Free | Yes
324340
*
341+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
342+
* Thread-safety is also affected by that of the `allocator` object associated with the
343+
* `clock` object.</i>
344+
*
325345
* \param[in] clock the handle to the clock which is being initialized
326346
* \return `RCL_RET_OK` if the time source was successfully finalized, or
327347
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
@@ -344,10 +364,14 @@ rcl_steady_clock_fini(
344364
* Attribute | Adherence
345365
* ------------------ | -------------
346366
* Allocates Memory | No
347-
* Thread-Safe | No
367+
* Thread-Safe | No [1]
348368
* Uses Atomics | No
349369
* Lock-Free | Yes
350370
*
371+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
372+
* Thread-safety is also affected by that of the `allocator` object associated with the
373+
* `clock` object.</i>
374+
*
351375
* \param[in] clock the handle to the clock which is being initialized
352376
* \param[in] allocator The allocator to use for allocations
353377
* \return `RCL_RET_OK` if the time source was successfully initialized, or
@@ -375,10 +399,14 @@ rcl_system_clock_init(
375399
* Attribute | Adherence
376400
* ------------------ | -------------
377401
* Allocates Memory | No
378-
* Thread-Safe | No
402+
* Thread-Safe | No [1]
379403
* Uses Atomics | No
380404
* Lock-Free | Yes
381405
*
406+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
407+
* Thread-safety is also affected by that of the `allocator` object associated with the
408+
* `clock` object.</i>
409+
*
382410
* \param[in] clock the handle to the clock which is being initialized.
383411
* \return `RCL_RET_OK` if the time source was successfully finalized, or
384412
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
@@ -433,7 +461,7 @@ rcl_difference_times(
433461
* Uses Atomics | Yes [1]
434462
* Lock-Free | Yes
435463
*
436-
* <i>[1] If `clock` is of `RCL_ROS_TIME` type</i>
464+
* <i>[1] If `clock` is of `RCL_ROS_TIME` type.</i>
437465
*
438466
* \param[in] clock The time source from which to set the value.
439467
* \param[out] time_point_value The time_point value to populate.
@@ -461,11 +489,12 @@ rcl_clock_get_now(rcl_clock_t * clock, rcl_time_point_value_t * time_point_value
461489
* Attribute | Adherence [1]
462490
* ------------------ | -------------
463491
* Allocates Memory | No
464-
* Thread-Safe | No
492+
* Thread-Safe | No [2]
465493
* Uses Atomics | No
466494
* Lock-Free | Yes
467495
*
468-
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it</i>
496+
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it.</i>
497+
* <i>[2] Function is reentrant, but concurrent calls on the same `clock` object are not safe.</i>
469498
*
470499
* \param[in] clock The clock to enable.
471500
* \return `RCL_RET_OK` if the time source was enabled successfully, or
@@ -491,11 +520,12 @@ rcl_enable_ros_time_override(rcl_clock_t * clock);
491520
* Attribute | Adherence [1]
492521
* ------------------ | -------------
493522
* Allocates Memory | No
494-
* Thread-Safe | No
523+
* Thread-Safe | No [2]
495524
* Uses Atomics | No
496525
* Lock-Free | Yes
497526
*
498-
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it</i>
527+
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it.</i>
528+
* <i>[2] Function is reentrant, but concurrent calls on the same `clock` object are not safe.</i>
499529
*
500530
* \param[in] clock The clock to disable.
501531
* \return `RCL_RET_OK` if the time source was disabled successfully, or
@@ -521,10 +551,12 @@ rcl_disable_ros_time_override(rcl_clock_t * clock);
521551
* Attribute | Adherence
522552
* ------------------ | -------------
523553
* Allocates Memory | No
524-
* Thread-Safe | No
554+
* Thread-Safe | No [1]
525555
* Uses Atomics | No
526556
* Lock-Free | Yes
527557
*
558+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.</i>
559+
*
528560
* \param[in] clock The clock to query.
529561
* \param[out] is_enabled Whether the override is enabled..
530562
* \return `RCL_RET_OK` if the time source was queried successfully, or
@@ -552,11 +584,12 @@ rcl_is_enabled_ros_time_override(
552584
* Attribute | Adherence [1]
553585
* ------------------ | -------------
554586
* Allocates Memory | No
555-
* Thread-Safe | No
587+
* Thread-Safe | No [2]
556588
* Uses Atomics | Yes
557589
* Lock-Free | Yes
558590
*
559-
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it</i>
591+
* <i>[1] Only applies to the function itself, as jump callbacks may not abide to it.</i>
592+
* <i>[2] Function is reentrant, but concurrent calls on the same `clock` object are not safe.</i>
560593
*
561594
* \param[in] clock The clock to update.
562595
* \param[in] time_value The new current time.
@@ -585,10 +618,14 @@ rcl_set_ros_time_override(
585618
* Attribute | Adherence
586619
* ------------------ | -------------
587620
* Allocates Memory | Yes
588-
* Thread-Safe | No
621+
* Thread-Safe | No [1]
589622
* Uses Atomics | No
590623
* Lock-Free | Yes
591624
*
625+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
626+
* Thread-safety is also affected by that of the `allocator` object associated with the
627+
* `clock` object.</i>
628+
*
592629
* \param[in] clock A clock to add a jump callback to.
593630
* \param[in] threshold Criteria indicating when to call the callback.
594631
* \param[in] callback A callback to call.
@@ -615,10 +652,14 @@ rcl_clock_add_jump_callback(
615652
* Attribute | Adherence
616653
* ------------------ | -------------
617654
* Allocates Memory | Yes
618-
* Thread-Safe | No
655+
* Thread-Safe | No [1]
619656
* Uses Atomics | No
620657
* Lock-Free | Yes
621658
*
659+
* <i>[1] Function is reentrant, but concurrent calls on the same `clock` object are not safe.
660+
* Thread-safety is also affected by that of the `allocator` object associated with the
661+
* `clock` object.</i>
662+
*
622663
* \param[in] clock The clock to remove a jump callback from.
623664
* \param[in] threshold Criteria indicating when to call callback.
624665
* \param[in] callback The callback to call.

0 commit comments

Comments
 (0)