Skip to content

Commit

Permalink
Zero copy api (#322)
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]>

* first draft loaned message sequence

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

* message info sequence

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

* rmw_take_loaned_message

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

* borrow/return & take/release

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

* introduce 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]>

* unify error messages

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

* linters

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 455d214 commit 09826ff
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 2 deletions.
14 changes: 14 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ rmw_publish_serialized_message(
return rmw_fastrtps_shared_cpp::__rmw_publish_serialized_message(
eprosima_fastrtps_identifier, publisher, serialized_message, allocation);
}

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_fastrtps_cpp");
return RMW_RET_UNSUPPORTED;
}
} // extern "C"
27 changes: 27 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,32 @@ rmw_publisher_get_actual_qos(
publisher, qos);
}

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_fastrtps_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_fastrtps_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher)
{
Expand Down
2 changes: 1 addition & 1 deletion rmw_fastrtps_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ rmw_create_subscription(
memcpy(const_cast<char *>(rmw_subscription->topic_name), topic_name, strlen(topic_name) + 1);

rmw_subscription->options = *subscription_options;

rmw_subscription->can_loan_messages = false;
return rmw_subscription;

fail:
Expand Down
46 changes: 46 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,52 @@ rmw_take_serialized_message_with_info(
allocation);
}

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_fastrtps_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_fastrtps_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_with_info not implemented for rmw_fastrtps_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_take_event(
const rmw_event_t * event_handle,
Expand Down
14 changes: 14 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ rmw_publish(
eprosima_fastrtps_identifier, publisher, ros_message, allocation);
}

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_fastrtps_dynamic_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_publish_serialized_message(
const rmw_publisher_t * publisher,
Expand Down
27 changes: 27 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,32 @@ rmw_publisher_get_actual_qos(
publisher, qos);
}

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 is not implemented for rmw_fastrtps_dynamic_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 is not implemented for rmw_fastrtps_dynamic_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_destroy_publisher(rmw_node_t * node, rmw_publisher_t * publisher)
{
Expand Down
2 changes: 1 addition & 1 deletion rmw_fastrtps_dynamic_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ rmw_create_subscription(
memcpy(const_cast<char *>(rmw_subscription->topic_name), topic_name, strlen(topic_name) + 1);

rmw_subscription->options = *subscription_options;

rmw_subscription->can_loan_messages = false;
return rmw_subscription;

fail:
Expand Down
47 changes: 47 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,53 @@ rmw_take_serialized_message_with_info(
allocation);
}

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 is not implemented for rmw_fastrtps_dynamic_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 is not implemented for rmw_fastrtps_dynamic_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 is not implemented for rmw_fastrtps_dynamic_cpp");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_take_event(
const rmw_event_t * event_handle,
Expand Down

0 comments on commit 09826ff

Please sign in to comment.