diff --git a/source/Tutorials/Demos/Intra-Process-Communication.rst b/source/Tutorials/Demos/Intra-Process-Communication.rst index ff350fec809..281075faa68 100644 --- a/source/Tutorials/Demos/Intra-Process-Communication.rst +++ b/source/Tutorials/Demos/Intra-Process-Communication.rst @@ -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 &`` (``ConstSharedPtr``) callback, which shares immutable ownership of the message and achieves zero-copy even with multiple subscribers, so long as a ``std::unique_ptr`` was passed to the publisher. +Subscribing with a plain ``const T &`` or a mutable ``std::shared_ptr`` will not achieve zero-copy. The cyclic pipeline demo ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -377,6 +378,9 @@ 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 &``) callbacks instead of ``UniquePtr``. +The message is promoted from the published ``UniquePtr`` to a ``ConstSharedPtr``, which is delivered to all intra-process subscribers as a single immutable shared object, without copying. + Pipeline with inter-process viewer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~