Function rmw_event_set_callback

Function Documentation

rmw_ret_t rmw_event_set_callback(rmw_event_t *event, rmw_event_callback_t callback, const void *user_data)

Set the callback function for the event.

This API sets the callback function to be called whenever the event is notified about a new instance of the event.

For example, this could be called when incompatible QoS is detected, or a deadline is missed, or any other QoS event.

This callback is called for each new event that occurs for this rmw_event_t instance. If events occur before the callback is registered, the number_of_events argument given to the callback may be > 1.

The callback may be called from a thread that the rmw implementation created, rather than a thread owned by the user, i.e. some thread other than user owned threads calling rmw functions such as rmw_wait() or rmw_publish().

This function is thread-safe. This is required of the rmw implementation because the callback may be called from any middleware thread, and this function could be called by the user at any time.

Parameters:
  • event[in] The event on which to set the callback

  • callback[in] The callback to be called when new events occur, can be NULL to clear the registered callback

  • user_data[in] Given to the callback when called later, may be NULL

Returns:

RMW_RET_OK if callback was set to the listener, or

Returns:

RMW_RET_INVALID_ARGUMENT if event is NULL, or

Returns:

RMW_RET_UNSUPPORTED if the API is not implemented in the dds implementation