Skip to content

Commit

Permalink
Respond to more review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Jan 4, 2022
1 parent 1779cd8 commit c8c4851
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class IntraProcessManager
template<
typename MessageT,
typename ROSMessageType,
typename Alloc = std::allocator<void>,
typename Alloc,
typename Deleter = std::default_delete<MessageT>
>
void
Expand Down Expand Up @@ -214,6 +214,8 @@ class IntraProcessManager
sub_ids.take_shared_subscriptions.size() <= 1)
{
// There is at maximum 1 buffer that does not require ownership.
// So this case is equivalent to all the buffers requiring ownership

// Merge the two vector of ids into a unique one
std::vector<uint64_t> concatenated_vector(sub_ids.take_shared_subscriptions);
concatenated_vector.insert(
Expand Down Expand Up @@ -241,7 +243,7 @@ class IntraProcessManager
template<
typename MessageT,
typename ROSMessageType,
typename Alloc = std::allocator<void>,
typename Alloc,
typename Deleter = std::default_delete<MessageT>
>
std::shared_ptr<const MessageT>
Expand Down Expand Up @@ -415,9 +417,9 @@ class IntraProcessManager

template<
typename MessageT,
typename Alloc = std::allocator<void>,
typename Deleter = std::default_delete<MessageT>,
typename ROSMessageType = MessageT>
typename Alloc,
typename Deleter,
typename ROSMessageType>
void
add_owned_msg_to_buffers(
std::unique_ptr<MessageT, Deleter> message,
Expand Down Expand Up @@ -457,13 +459,11 @@ class IntraProcessManager
subscription->provide_intra_process_data(std::move(message));
} else {
// Copy the message since we have additional subscriptions to serve
MessageUniquePtr copy_message;
Deleter deleter = message.get_deleter();
auto ptr = MessageAllocTraits::allocate(allocator, 1);
MessageAllocTraits::construct(allocator, ptr, *message);
copy_message = MessageUniquePtr(ptr, deleter);

subscription->provide_intra_process_data(std::move(copy_message));
subscription->provide_intra_process_data(std::move(MessageUniquePtr(ptr, deleter)));
}

continue;
Expand Down Expand Up @@ -498,14 +498,13 @@ class IntraProcessManager
ros_message_subscription->provide_intra_process_message(std::move(message));
} else {
// Copy the message since we have additional subscriptions to serve
MessageUniquePtr copy_message;
Deleter deleter = message.get_deleter();
allocator::set_allocator_for_deleter(&deleter, &allocator);
auto ptr = MessageAllocTraits::allocate(allocator, 1);
MessageAllocTraits::construct(allocator, ptr, *message);
copy_message = MessageUniquePtr(ptr, deleter);

ros_message_subscription->provide_intra_process_message(std::move(copy_message));
ros_message_subscription->provide_intra_process_message(
std::move(MessageUniquePtr(ptr, deleter)));
}
}
}
Expand Down

0 comments on commit c8c4851

Please sign in to comment.