ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Synchronous / asynchronous in this context refers to the queuing of the published message.
The triggering of the callback of subscribers is always asynchronous. So when the publish()
call returns the subcriber has not been invoked yet.
If the queuing is synchronous the publish()
call returns after the message has been serialized and written to the buffer of each connection. In the case where the subscriber on a network connection isn't reading the data fast enough the buffer of the socket might get full which would make the call block until after the buffer has been emptied enough to take the message. So this would block even if only a single of N connections is not draining the data quickly enough.
If the queuing is asynchronous the publish()
call will never block. The message is serialized into a queue (actually multiple queues, one per connection) and the call returns before the data is actually written to the socket(s). Separate threads will then write the data from the queues to the sockets.
As mentioned already in Python you can choose by passing either a queues size or None
. In C++ you can only pass a queue size.