Topic fix writer interface issue 2#867
Conversation
|
Change interface name from |
jhdcs
left a comment
There was a problem hiding this comment.
This looks fairly good to me. Just a few mild suggestions. The one I'm most interested in seeing is the preservation of the comment in writer.cpp, the others are mostly just mild style stuff.
rosbag2_compression/src/rosbag2_compression/sequential_compression_writer.cpp
Outdated
Show resolved
Hide resolved
|
I added a new commit since I found below case. So for this case, need to call SequentialWriter::request_owned_serialized_data() to check. |
| [](rcutils_uint8_array_t * /* data */) {}); | ||
| if (writer_impl_->request_owned_serialized_data()) { | ||
| // Need owned serialized data, so duplicate message | ||
| serialized_bag_message->serialized_data = std::shared_ptr<rcutils_uint8_array_t>( |
There was a problem hiding this comment.
Please pull this duplicating logic into a separate helper function for readability. I think this should look something like:
std::shared_ptr<rosbag2_storage::SerializedBagMessage> serialized_bag_message;
if (writer_impl_->needs_message_ownership()) {
copy_message_into(message, serialized_bag_message);
} else {
// temporary store the payload in a shared_ptr.
// add custom no-op deleter to avoid deep copying data.
serialized_bag_message->serialized_data = std::shared_ptr<rcutils_uint8_array_t>(
const_cast<rcutils_uint8_array_t *>(&message.get_rcl_serialized_message()),
[](rcutils_uint8_array_t * /* data */) {});
}
return write(serialized_bag_message, topic_name, type_name, rmw_get_serialization_format());
| serialized_bag_message->serialized_data = std::shared_ptr<rcutils_uint8_array_t>( | ||
| const_cast<rcutils_uint8_array_t *>(&message.get_rcl_serialized_message()), | ||
| [](rcutils_uint8_array_t * /* data */) {}); | ||
| if (writer_impl_->request_owned_serialized_data()) { |
There was a problem hiding this comment.
While we are adding these workarounds, can you also mark this function signature as [[deprecated()]] in the header? Based on the need to duplicate every message like this, I think we want to discourage its use and remove it later
There was a problem hiding this comment.
But this interface is called now by below template interface
rosbag2/rosbag2_cpp/include/rosbag2_cpp/writer.hpp
Lines 149 to 170 in 622b0ad
So I think we also need to modify this template interface.
I want to use this new interface to replace this interface to be deprecated.
https://github.com/Barry-Xu-2018/rosbag2/blob/5f18ae59f1358ae045e1e4b14afadbc333a8737d/rosbag2_cpp/include/rosbag2_cpp/writer.hpp#L149-L166
New interface also can be called instead of below codes.
rosbag2/rosbag2_transport/src/rosbag2_transport/recorder.cpp
Lines 222 to 246 in 622b0ad
What do you think ?
|
|
||
| virtual void write(std::shared_ptr<rosbag2_storage::SerializedBagMessage> message) = 0; | ||
|
|
||
| virtual bool request_owned_serialized_data() = 0; |
There was a problem hiding this comment.
Non-blocking: This feels very much like an under-the-hood implementation detail. It would be nice if we could avoid exposing it to the global interface. However - I don't know if we can do that right now. We may just need to wait until we remove the write(SerializedBagMessage &) interface.
There was a problem hiding this comment.
Currently, I not find better way instead of adding hook function to global interface.
|
Friendly ping @emersonknapp |
… mode to write data Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
deb554d to
bad0909
Compare
|
Do rebase |
|
There is new way to avoid adding a new interface. |
|
After deep consider, I think we should not modify so much codes for a deprecated interface. So I want to discard this commit. |
|
@Barry-Xu-2018 I have approved the other PR and will merge after it passes CI. Do we still need this PR at all? |
No. I close this PR. |
Address #856
Comparing with fix #866, add new interface
is_async_process_messageto BaseWriterInterface.This new interface can help to get information about if the processing message is asynchronous.
So we can know whether message need to be duplicated.