Skip to content

Commit

Permalink
Add rmw_publisher_wait_for_all_acked support (#296)
Browse files Browse the repository at this point in the history
Signed-off-by: Barry Xu <[email protected]>
  • Loading branch information
Barry-Xu-2018 authored Jun 2, 2021
1 parent f9f4ef4 commit 2c58d9a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,51 @@ RMW_WARN_UNUSED
rmw_ret_t
rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher);

/// Wait until all published message data is acknowledged or until the specified timeout elapses.
/**
* This function waits until all published message data were acknowledged by peer node or timeout.
*
* This function only works effectively while QOS profile of publisher is set to RELIABLE.
* Otherwise this function will immediately return RMW_RET_OK.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Maybe [1]
* Thread-Safe | Yes
* Uses Atomics | Maybe [1]
* Lock-Free | Maybe [1]
* <i>[1] rmw implementation defined, check the implementation documentation</i>
*
* \par Runtime behavior
* Waiting for all acknowledgments is synchronous operation.
* So the calling thread is blocked until all published message data is acknowledged or specified
* duration elapses.
*
* \par Thread-Safety
* Publishers are thread-safe objects, and so are all operations on them except for finalization.
* Therefore, it is safe to call this function using the same publisher concurrently.
*
* \pre Given `publisher` must be a valid publisher, as returned by rmw_create_publisher().
*
* \param[in] publisher handle to the publisher that needs to wait for all acked.
* \param[in] wait_timeout represents the maximum amount of time to wait for all published message
* data were acknowledged.
* \return `RMW_RET_OK` if successful, or
* \return `RMW_RET_TIMEOUT` if wait timed out, or
* \return `RMW_RET_INVALID_ARGUMENT` if `publisher` is `NULL`, or
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the `publisher` implementation
* identifier does not match this implementation, or
* \return `RMW_RET_ERROR` if an unspecified error occurs, or
* \return `RMW_RET_UNSUPPORTED` if the rmw implementation is unimplemented.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_publisher_wait_for_all_acked(
const rmw_publisher_t * publisher,
rmw_time_t wait_timeout);

/// Serialize a ROS message into a rmw_serialized_message_t.
/**
* The ROS message is serialized into a byte stream contained within the
Expand Down

0 comments on commit 2c58d9a

Please sign in to comment.