Skip to content

Commit

Permalink
can_loan_messages for subscription
Browse files Browse the repository at this point in the history
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
  • Loading branch information
Karsten1987 committed Sep 28, 2019
1 parent 5584759 commit 8e86714
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ RCL_WARN_UNUSED
const rmw_qos_profile_t *
rcl_subscription_get_actual_qos(const rcl_subscription_t * subscription);

/// Check if subscription instance can loan messages.
/**
* Depending on the middleware and the message type, this will return true if the middleware
* can allocate a ROS message instance.
*/
RCL_PUBLIC
bool
rcl_subscription_can_loan_messages(const rcl_subscription_t * subscription);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ rcl_allocate_loaned_message(
size_t message_size)
{
if (!rcl_publisher_is_valid(publisher)) {
return RCL_RET_PUBLISHER_INVALID; // error already set
return NULL; // error already set
}
return rmw_allocate_loaned_message(publisher->impl->rmw_handle, type_support, message_size);
}
Expand Down
9 changes: 9 additions & 0 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ rcl_subscription_get_actual_qos(const rcl_subscription_t * subscription)
return &subscription->impl->actual_qos;
}

bool
rcl_subscription_can_loan_messages(const rcl_subscription_t * subscription)
{
if (!rcl_subscription_is_valid(subscription)) {
return false; // error message already set
}
return subscription->impl->rmw_handle->can_loan_messages;
}

#ifdef __cplusplus
}
#endif

0 comments on commit 8e86714

Please sign in to comment.