Skip to content

Commit caf4d09

Browse files
mini-1235fujitatomoya
authored andcommitted
Fix IPC tutorial
Signed-off-by: Maurice <[email protected]>
1 parent d7313c0 commit caf4d09

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

source/Tutorials/Demos/Intra-Process-Communication.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ Let's run it with the command:
363363
Just like the last example, you can pause the rendering with the spacebar and continue by pressing the spacebar a second time.
364364
You can stop the updating to inspect the pointers written to the screen.
365365

366-
As you can see in the example image above, we have one image with all of the pointers the same and then another image with the same pointers as the first image for the first two entries, but the last pointer on the second image is different.
366+
As you can see in the example image above, both image windows show the same memory addresses for all three pointers.
367+
This demonstrates that all nodes are sharing the same message instance through zero-copy intra-process communication.
367368
To understand why this is happening consider the graph's topology:
368369

369370
.. code-block:: bash
@@ -372,15 +373,13 @@ To understand why this is happening consider the graph's topology:
372373
-> image_view_node2
373374
374375
The link between the ``camera_node`` and the ``watermark_node`` can use the same pointer without copying because there is only one intra process subscription to which the message should be delivered.
375-
But for the link between the ``watermark_node`` and the two image view nodes the relationship is one to many, so if the image view nodes were using ``unique_ptr`` callbacks then it would be impossible to deliver the ownership of the same pointer to both.
376-
It can be, however, delivered to one of them.
377-
Which one would get the original pointer is not defined, but instead is simply the last to be delivered.
378376

377+
For the link between the ``watermark_node`` and the two image view nodes the relationship is one to many.
379378
Note that the image view nodes are not subscribed with ``unique_ptr`` callbacks.
380379
Instead they are subscribed with ``const shared_ptr``\ s.
381-
This means the system deliveres the same ``shared_ptr`` to both callbacks.
382380
When the first intraprocess subscription is handled, the internally stored ``unique_ptr`` is promoted to a ``shared_ptr``.
383-
Each of the callbacks will receive shared ownership of the same message.
381+
The system then delivers the same ``shared_ptr`` to both callbacks, allowing each callback to receive shared ownership of the same message.
382+
This means all six addresses shown in the image windows will be identical, demonstrating efficient zero-copy memory sharing even in a one-to-many publisher-subscriber relationship.
384383

385384
Pipeline with interprocess viewer
386385
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-67.2 KB
Loading

0 commit comments

Comments
 (0)