Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero copy api #322

Merged
merged 13 commits into from
Oct 18, 2019
Next Next commit
allocate loaned message
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
  • Loading branch information
Karsten1987 committed Oct 17, 2019
commit df5f7bc8494f32725eeb314aede40be33bb4bc09
7 changes: 6 additions & 1 deletion rmw_fastrtps_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ rmw_ret_t
rmw_publish(
const rmw_publisher_t * publisher,
const void * ros_message,
rmw_publisher_allocation_t * allocation)
rmw_publisher_allocation_t * allocation,
bool is_loaned)
{
if (is_loaned) {
RMW_SET_ERROR_MSG("fastrtps does not support loaned messages");
return RMW_RET_ERROR;
}
return rmw_fastrtps_shared_cpp::__rmw_publish(
eprosima_fastrtps_identifier, publisher, ros_message, allocation);
}
Expand Down
25 changes: 25 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ rmw_create_publisher(
RMW_SET_ERROR_MSG("failed to allocate publisher");
goto fail;
}
rmw_publisher->can_loan_messages = false;
rmw_publisher->implementation_identifier = eprosima_fastrtps_identifier;
rmw_publisher->data = info;
rmw_publisher->topic_name = reinterpret_cast<char *>(rmw_allocate(strlen(topic_name) + 1));
Expand Down Expand Up @@ -260,6 +261,30 @@ rmw_publisher_get_actual_qos(
publisher, qos);
}

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
7 changes: 6 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ rmw_ret_t
rmw_publish(
const rmw_publisher_t * publisher,
const void * ros_message,
rmw_publisher_allocation_t * allocation)
rmw_publisher_allocation_t * allocation,
bool is_loaned)
{
if (is_loaned) {
RMW_SET_ERROR_MSG("fastrtps dynamic does not support loaned messages");
return RMW_RET_ERROR;
}
return rmw_fastrtps_shared_cpp::__rmw_publish(
eprosima_fastrtps_identifier, publisher, ros_message, allocation);
}
Expand Down
25 changes: 25 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ rmw_create_publisher(
RMW_SET_ERROR_MSG("failed to allocate publisher");
goto fail;
}
rmw_publisher->can_loan_messages = false;
rmw_publisher->implementation_identifier = eprosima_fastrtps_identifier;
rmw_publisher->data = info;
rmw_publisher->topic_name = reinterpret_cast<char *>(rmw_allocate(strlen(topic_name) + 1));
Expand Down Expand Up @@ -256,6 +257,30 @@ rmw_publisher_get_actual_qos(
publisher, qos);
}

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