Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion source/Tutorials/Demos/Intra-Process-Communication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ In this case, since they only come once per second, usually only the first messa
Finally, you can see that "Published message..." and "Received message ..." lines with the same value also have the same address.
This shows that the address of the message being received is the same as the one that was published and that it is not a copy.
This is because we're publishing and subscribing with ``std::unique_ptr``\ s which allow ownership of a message to be moved around the system safely.
You can also publish and subscribe with ``const &`` and ``std::shared_ptr``, but zero-copy will not occur in that case.
You can also subscribe using a ``const std::shared_ptr<const T> &`` (``ConstSharedPtr``) callback, which shares immutable ownership of the message and achieves zero-copy even with multiple subscribers.
Comment thread
MShields1986 marked this conversation as resolved.
Outdated
Comment thread
MShields1986 marked this conversation as resolved.
Outdated
Subscribing with a mutable ``std::shared_ptr<T>`` will not achieve zero-copy.

The cyclic pipeline demo
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -377,6 +378,12 @@ It can be, however, delivered to one of them.
Which one would get the original pointer is not defined, but instead is simply the last to be delivered.
And so one of the images being viewed is the original, with all the pointers the same, and the other is a copy of the original image, made between the ``watermark_node`` and one of the ``image_view_node`` instances, which will have a different pointer for the third line of text.

To avoid this copy in a one-to-many pipeline, subscribers can use ``ConstSharedPtr``
(i.e. ``const std::shared_ptr<const T> &``) callbacks instead of ``UniquePtr``.
The publisher retains a single immutable shared object and delivers it to all intra-process
subscribers without copying, at the cost of no longer being able to mutate the message after
publishing.
Comment thread
MShields1986 marked this conversation as resolved.
Outdated

Pipeline with inter-process viewer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down