You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/Tutorials/Demos/Intra-Process-Communication.rst
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -363,7 +363,8 @@ Let's run it with the command:
363
363
Just like the last example, you can pause the rendering with the spacebar and continue by pressing the spacebar a second time.
364
364
You can stop the updating to inspect the pointers written to the screen.
365
365
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.
367
368
To understand why this is happening consider the graph's topology:
368
369
369
370
.. code-block:: bash
@@ -372,15 +373,13 @@ To understand why this is happening consider the graph's topology:
372
373
-> image_view_node2
373
374
374
375
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.
378
376
377
+
For the link between the ``watermark_node`` and the two image view nodes the relationship is one to many.
379
378
Note that the image view nodes are not subscribed with ``unique_ptr`` callbacks.
380
379
Instead they are subscribed with ``const shared_ptr``\ s.
381
-
This means the system deliveres the same ``shared_ptr`` to both callbacks.
382
380
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.
0 commit comments