-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and remove subscription from waitset depending on wait state #98
base: master
Are you sure you want to change the base?
Add and remove subscription from waitset depending on wait state #98
Conversation
5fa069d
to
6985a0c
Compare
6985a0c
to
09f9819
Compare
@m-dahl What do you think about the approach in this PR? Do you agree with my problem diagnosis? Would you merge a version of this PR that implements the shown approach for all the |
Hi Tobias, I really appreciate this work, removing the intermediate channels will be a nice improvement. The channels are there mostly because they were easy to implement when I did the switch to async years ago, but this is much better and more direct. I can't really see any downside to the approach as long as the guard condition is correctly implemented. I will be happy to merge this once finished. We should make sure its well tested. (I don't really trust the tests that failed in the CI run for this PR, those need to be improved as well). I don't have much time right now but in a couple of weeks I will be able dig in to this and improve the tests. In the meantime I can try to support if you need anything. |
@m-dahl FYI, I haven't forgotten about this PR. It just turns out to be trickier than I thought due to the teardown behaviour. As you know I'm still trying to figure out what the best way to handle this is. My current plan is to have some sort of flag (either atomic or mutex-protected) next to the
What do you think? Does that make sense? |
c81dc6f
to
ba50f0f
Compare
My apologies for not getting back to you sooner. I haven't had time for open source stuff lately, was hoping to look in to this during summer but it never happened. Did you ever implement this idea? I think the plan you describe makes sense but curious if there were any other challenges. |
No worries, I was having similar issues on our side internally. I have an implementation for the approach, but I didn't have a good opportunity to test this internally through the summer. We recently picked this up again and are currently in the process of testing things out. Once we're done with our testing cycle here I'll push an updated version and get back to you. |
The current subscriber handler suffers from a busy-waiting loop if r2rs internal 10-element queue fills up. If that ever happens,
handle_incoming
will return immediately whenever invoked by the waitset and the waitset will wake immediately when going to sleep.This PR addresses this issue by removing the internal message queue between waitset and subscriber. Instead, it explicitly implements the Stream interface for ROS subscribers, adding them to the waitset if and only if someone is actually blocking for new messages. This ensures that a subscriber that falls behind and queues up messages in the (DDS) queue never wakes the waitset.
As a proof of concept (and to facilitate discussion of the approach), only the regular
TypedSubscriber
is implemented for now. The other subscriber- and service types will be implemented analogously once agreement on the approach is achieved.