ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
One possible solution would be to modify shutdown
as such:
Publisher::shutdown(bool sendQueuedMessages = false)
.
Calling shutdown
with true
would "kill" the instance as usual, but the TopicManager
would not call Publication::drop()
but rather mark the Publication
as isShuttingDown=true
.
At the next call to processPublishQueues()
, after sending all messages, the TopicManager
would call drop()
on all Publication
instances marked to be shut down.
In the case where a new publisher for the same topic gets created in the mean time (after shutdown
but before processPublishQueues
), the TopicManager
would simply unmark the Publication
as shutting down.
2 | Added an alternative solution |
One possible solution would be to modify shutdown
as such:
Publisher::shutdown(bool sendQueuedMessages = false)
.
Calling shutdown
with true
would "kill" the instance as usual, but the TopicManager
would not call Publication::drop()
but rather mark the Publication
as isShuttingDown=true
.
At the next call to processPublishQueues()
, after sending all messages, the TopicManager
would call drop()
on all Publication
instances marked to be shut down.
In the case where a new publisher for the same topic gets created in the mean time (after shutdown
but before processPublishQueues
), the TopicManager
would simply unmark the Publication
as shutting down.
Another possibility would be to create a method Publisher::areQueuesEmpty()
. The Publisher
would ask the TopicManager
, which would ask the Publication
, which would ask all SubscriberLink
s. Only if all queues for all subscribers are empty would the method return true. The developers would then have to manually manage when they shut down the publisher.