[rcl_action] Add function to check if goal can be transitioned to CANCELING (#325)

* [rcl_action] Add function for checking if goal can be transitioned to CANCELING

Add unit tests for the new function rcl_action_goal_handle_is_cancelable(), as well as rcl_action_goal_handle_is_active().
This commit is contained in:
Jacob Perron 2018-11-13 11:55:28 -08:00 committed by GitHub
parent 9351fd89c7
commit 8b00791a56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 45 deletions

View file

@ -202,15 +202,37 @@ rcl_action_goal_handle_get_status(
* Lock-Free | Yes
*
* \param[in] goal_handle struct containing the goal and metadata
* \return `true` if a goal is in one of the following states: ACCEPTED, EXECUTING, or CANCELING, or
* \return `false` otherwise, also
* \return `false` if the goal handle pointer is invalid
* \return `true` if the goal is in one of the following states: ACCEPTED, EXECUTING, or CANCELING, or
* \return `false` if the goal handle pointer is invalid, or
* \return `false` otherwise
*/
RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
bool
rcl_action_goal_handle_is_active(const rcl_action_goal_handle_t * goal_handle);
/// Check if a goal can be transitioned to CANCELING in its current state.
/**
* This is a non-blocking call.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] goal_handle struct containing the goal and metadata
* \return `true` if the goal can be transitioned to CANCELING from its current state, or
* \return `false` if the goal handle pointer is invalid, or
* \return `false` otherwise
*/
RCL_ACTION_PUBLIC
RCL_WARN_UNUSED
bool
rcl_action_goal_handle_is_cancelable(const rcl_action_goal_handle_t * goal_handle);
/// Check if a rcl_action_goal_handle_t is valid.
/**
* This is a non-blocking call.
@ -229,8 +251,9 @@ rcl_action_goal_handle_is_active(const rcl_action_goal_handle_t * goal_handle);
* Lock-Free | Yes
*
* \param[in] goal_handle struct to evaluate as valid or not
* \return `true` if the goal handle is valid, `false` otherwise, also
* \return `false` if the goal handle pointer is null
* \return `true` if the goal handle is valid, or
* \return `false` if the goal handle pointer is null, or
* \return `false` otherwise
*/
RCL_ACTION_PUBLIC
RCL_WARN_UNUSED