diff --git a/articles/intraprocess_communication.md b/articles/intraprocess_communication.md index 56e0a467..2696100d 100644 --- a/articles/intraprocess_communication.md +++ b/articles/intraprocess_communication.md @@ -329,7 +329,7 @@ If all the `Subscription`s want ownership of the message, then a total of `N-1` The last one will receive ownership of the published message, thus saving a copy. If none of the `Subscription`s want ownership of the message, `0` copies are required. -It is possible to convert the message into a `std::shared_ptr msg` and to add it to every buffer. +It is possible to convert the message into a `std::shared_ptr msg` and to add it to every buffer. If there is 1 `Subscription` that does not want ownership while the others want it, the situation is equivalent to the case of everyone requesting ownership:`N-1` copies of the message are required. As before the last `Subscription` will receive ownership. @@ -351,29 +351,17 @@ The notation `@` indicates a memory address where the message is stored, differe | ----------------------- | ----------------------- | ----------------------- | | unique_ptr\ @1 | unique_ptr\ | @1 | | unique_ptr\ @1 | unique_ptr\
unique_ptr\ | @1
@2 | -| unique_ptr\ @1 | shared_ptr\ | @1 | -| unique_ptr\ @1 | shared_ptr\
shared_ptr\ | @1
@1 | -| unique_ptr\ @1 | unique_ptr\
shared_ptr\ | @1
@2 | -| unique_ptr\ @1 | unique_ptr\
shared_ptr\
shared_ptr\ | @1
@2
@2| -| unique_ptr\ @1 | unique_ptr\
unique_ptr\
shared_ptr\
shared_ptr\ | @1
@2
@3
@3| - -#### Publishing SharedPtr - -| publish\ | BufferT | Results | -| ----------------------- | ----------------------- | ----------------------- | -| shared_ptr\ @1 | unique_ptr\ | @2 | -| shared_ptr\ @1 | unique_ptr\
unique_ptr\ | @2
@3 | -| shared_ptr\ @1 | shared_ptr\ | @1 | -| shared_ptr\ @1 | shared_ptr\
shared_ptr\ | @1
@1 | -| shared_ptr\ @1 | unique_ptr\
shared_ptr\ | @2
@1 | -| shared_ptr\ @1 | unique_ptr\
shared_ptr\
shared_ptr\ | @2
@1
@1| -| shared_ptr\ @1 | unique_ptr\
unique_ptr\
shared_ptr\
shared_ptr\ | @2
@3
@1
@1| +| unique_ptr\ @1 | shared_ptr\ | @1 | +| unique_ptr\ @1 | shared_ptr\
shared_ptr\ | @1
@1 | +| unique_ptr\ @1 | unique_ptr\
shared_ptr\ | @1
@2 | +| unique_ptr\ @1 | unique_ptr\
shared_ptr\
shared_ptr\ | @1
@2
@2| +| unique_ptr\ @1 | unique_ptr\
unique_ptr\
shared_ptr\
shared_ptr\ | @1
@2
@3
@3| The possibility of setting the data-type stored in each buffer becomes helpful when dealing with more particular scenarios. Considering a scenario with N `Subscription`s all taking a unique pointer. If the `Subscription`s don't actually take the message (e.g. they are busy and the message is being overwritten due to QoS settings) the default buffer type (`unique_ptr` since the callbacks require ownership) would result in the copy taking place anyway. -By setting the buffer type to `shared_ptr`, no copies are needed when the `Publisher` pushes messages into the buffers. +By setting the buffer type to `shared_ptr`, no copies are needed when the `Publisher` pushes messages into the buffers. Eventually, the `Subscription`s will copy the data only when they are ready to process it. On the other hand, if the published data are very small, it can be advantageous to do not use C++ smart pointers, but to directly store the data into the buffers.