Function rcl_timer_call

Function Documentation

rcl_ret_t rcl_timer_call(rcl_timer_t *timer)

Call the timer’s callback and set the last call time.

This function will call the callback and change the last call time even if the timer’s period has not yet elapsed. It is up to the calling code to make sure the period has elapsed by first calling rcl_timer_is_ready(). If the callback pointer is NULL (either set in init or exchanged after initialized), no callback is fired. However, this function should still be called by the client library to update the state of the timer. The order of operations in this command are as follows:

  • Ensure the timer has not been canceled.

  • Get the current time into a temporary rcl_steady_time_point_t.

  • Exchange the current time with the last call time of the timer.

  • Call the callback, passing this timer and the time since the last call.

  • Return after the callback has completed.

During the callback the timer can be canceled or have its period and/or callback modified.

Attribute

Adherence

Allocates Memory

No

Thread-Safe

Yes [1]

Uses Atomics

Yes

Lock-Free

Yes [2]

[1] user callback might not be thread-safe

[2] if returns true for

Parameters:

timer[inout] the handle to the timer to call

Returns:

RCL_RET_OK if the timer was called successfully, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_TIMER_INVALID if the timer->impl is invalid, or

Returns:

RCL_RET_TIMER_CANCELED if the timer has been canceled, or

Returns:

RCL_RET_ERROR an unspecified error occur.