Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Zero copy api (#367)
Browse files Browse the repository at this point in the history
* allocate loaned message

Signed-off-by: Karsten Knese <[email protected]>

* can_loan_messages for subscription

Signed-off-by: Karsten Knese <[email protected]>

* ignore whether message is loaned on publish

Signed-off-by: Karsten Knese <[email protected]>

* borrow/return & take/release

Signed-off-by: Karsten Knese <[email protected]>

* rmw_publish_loaned_message

Signed-off-by: Karsten Knese <[email protected]>

* const correct publish

Signed-off-by: Karsten Knese <[email protected]>

* remove loaned message sequence

Signed-off-by: Knese Karsten <[email protected]>

* remove extra line

Signed-off-by: Karsten Knese <[email protected]>

* connext dynamic - rmw_publish_loaned_message

Signed-off-by: Karsten Knese <[email protected]>

* unify error messages

Signed-off-by: Karsten Knese <[email protected]>

* use RMW_RET_UNSUPPORTED

Signed-off-by: Karsten Knese <[email protected]>
  • Loading branch information
Karsten1987 authored Oct 18, 2019
1 parent 9d8477f commit 394d9cf
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rmw_connext_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,18 @@ rmw_publish_serialized_message(
}
return RMW_RET_OK;
}

rmw_ret_t
rmw_publish_loaned_message(
const rmw_publisher_t * publisher,
void * ros_message,
rmw_publisher_allocation_t * allocation)
{
(void) publisher;
(void) ros_message;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_publish_loaned_message not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}
} // extern "C"
27 changes: 27 additions & 0 deletions rmw_connext_cpp/src/rmw_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ rmw_create_publisher(
RMW_SET_ERROR_MSG("failed to allocate publisher");
goto fail;
}
publisher->can_loan_messages = false;

type_code = callbacks->get_type_code();
if (!type_code) {
Expand Down Expand Up @@ -422,6 +423,32 @@ rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher)
return RMW_RET_OK;
}

rmw_ret_t
rmw_borrow_loaned_message(
const rmw_publisher_t * publisher,
const rosidl_message_type_support_t * type_support,
void ** ros_message)
{
(void) publisher;
(void) type_support;
(void) ros_message;

RMW_SET_ERROR_MSG("rmw_borrow_loaned_message not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_return_loaned_message(
const rmw_publisher_t * publisher,
void * loaned_message)
{
(void) publisher;
(void) loaned_message;

RMW_SET_ERROR_MSG("rmw_return_loaned_message not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher)
{
Expand Down
1 change: 1 addition & 0 deletions rmw_connext_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ rmw_create_subscription(
fprintf(stderr, "******\n");
#endif

subscription->can_loan_messages = false;
return subscription;
fail:
if (topic_str) {
Expand Down
46 changes: 46 additions & 0 deletions rmw_connext_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,50 @@ rmw_take_serialized_message_with_info(

return RMW_RET_OK;
}

rmw_ret_t
rmw_take_loaned_message(
const rmw_subscription_t * subscription,
void ** loaned_message,
bool * taken,
rmw_subscription_allocation_t * allocation)
{
(void) subscription;
(void) loaned_message;
(void) taken;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_take_loaned_message not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_take_loaned_message_with_info(
const rmw_subscription_t * subscription,
void ** loaned_message,
bool * taken,
rmw_message_info_t * message_info,
rmw_subscription_allocation_t * allocation)
{
(void) subscription;
(void) loaned_message;
(void) taken;
(void) message_info;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_take_loaned_message_with_info not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_release_loaned_message(
const rmw_subscription_t * subscription,
void * loaned_message)
{
(void) subscription;
(void) loaned_message;

RMW_SET_ERROR_MSG("rmw_release_loaned_message not implemented for rmw_connext_cpp");
return RMW_RET_UNSUPPORTED;
}
} // extern "C"
127 changes: 127 additions & 0 deletions rmw_connext_dynamic_cpp/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ rmw_create_publisher(
RMW_SET_ERROR_MSG("failed to allocate memory for publisher");
goto fail;
}
publisher->can_loan_messages = false;

type_code = _create_type_code(
type_name, type_support->data, type_support->typesupport_identifier);
Expand Down Expand Up @@ -680,6 +681,46 @@ rmw_create_publisher(
return NULL;
}

rmw_ret_t
rmw_publish_loaned_message(
const rmw_publisher_t * publisher,
void * ros_message,
rmw_publisher_allocation_t * allocation)
{
(void) publisher;
(void) ros_message;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_publish_loaned_message not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_borrow_loaned_message(
const rmw_publisher_t * publisher,
const rosidl_message_type_support_t * type_support,
void ** ros_message)
{
(void) publisher;
(void) type_support;
(void) ros_message;

RMW_SET_ERROR_MSG("rmw_borrow_loaned_message not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_return_loaned_message(
const rmw_publisher_t * publisher,
void * loaned_message)
{
(void) publisher;
(void) loaned_message;

RMW_SET_ERROR_MSG("rmw_return_loaned_message not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_OK;
}

rmw_ret_t
rmw_publisher_get_actual_qos(
const rmw_publisher_t * publisher,
Expand Down Expand Up @@ -747,6 +788,30 @@ rmw_publisher_get_actual_qos(
return RMW_RET_OK;
}

void *
rmw_allocate_loaned_message(
const rmw_publisher_t * publisher,
const rosidl_message_type_support_t * type_support,
size_t message_size)
{
(void) publisher;
(void) type_support;
(void) message_size;

return nullptr;
}

rmw_ret_t
rmw_deallocate_loaned_message(
const rmw_publisher_t * publisher,
void * loaned_message)
{
(void) publisher;
(void) loaned_message;

return RMW_RET_OK;
}

rmw_ret_t
rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher)
{
Expand Down Expand Up @@ -926,6 +991,20 @@ rmw_publish_serialized_message(
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_publish_loaned_message(
const rmw_publisher_t * publisher,
void * ros_message,
rmw_publisher_allocation_t * allocation)
{
(void) publisher;
(void) ros_message;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_publish_loaned_message is not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_subscription_t *
rmw_create_subscription(
const rmw_node_t * node,
Expand Down Expand Up @@ -1133,6 +1212,7 @@ rmw_create_subscription(
EntityType::Subscriber);
node_info->subscriber_listener->trigger_graph_guard_condition();

subscription->can_loan_messages = false;
return subscription;
fail:
// Something has gone wrong, unroll what has been done.
Expand Down Expand Up @@ -1507,6 +1587,53 @@ rmw_take_serialized_message_with_info(
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_take_loaned_message(
const rmw_subscription_t * subscription,
void ** loaned_message,
bool * taken,
rmw_subscription_allocation_t * allocation)
{
(void) subscription;
(void) loaned_message;
(void) taken;
(void) allocation;

RMW_SET_ERROR_MSG("rmw_take_loaned_message not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_take_loaned_message_with_info(
const rmw_subscription_t * subscription,
void ** loaned_message,
bool * taken,
rmw_message_info_t * message_info,
rmw_subscription_allocation_t * allocation)
{
(void) subscription;
(void) loaned_message;
(void) taken;
(void) message_info;
(void) allocation;

RMW_SET_ERROR_MSG(
"rmw_take_loaned_message_with_info not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_release_loaned_message(
const rmw_subscription_t * subscription,
void * loaned_message)
{
(void) subscription;
(void) loaned_message;

RMW_SET_ERROR_MSG("rmw_release_loaned_message not implemented for rmw_connext_dynamic_cpp");
return RMW_RET_ERROR;
}

rmw_ret_t
rmw_serialize(
const void * ros_message,
Expand Down

0 comments on commit 394d9cf

Please sign in to comment.