Skip to content
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

Simplify implementation of CallbackQueue::callOne() #1

Conversation

meyerj
Copy link

@meyerj meyerj commented Jun 18, 2019

I was working on an ABI-compatible solution for ros#1545 because we were also affected by this problem. Only afterwards I found your PR ros#1684 based on what @peci1 suggested in ros#1608. I came up with a similar solution and merged it at the end. Maybe it would be good to explicitly reference ros#1684 in ros#1608 and close the latter?

I suggest to replace the duplicate wait_for() call in CallbackQueue::callOne() with a loop and a single call to wait_until(). There is also no need to calculate the remaining duration of the timeout explicitly.

The behavior is slightly different: callOne(timeout) only returns TryAgain if the timeout expired and none of the callbacks in the queue was ready. If one of the callbacks gets ready within the given timeout, it will be called without returning to the caller. That does not make a significant difference at the end if the caller invokes callOne() again immediately like the spinner does.

I needed the BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC to be defined because I am currently testing with Boost 1.58 in Ubuntu 16.04 (custom melodic build) (ros#1684 (comment)). If it gets removed, the BOOST_VERSION check in line 44-50 should be removed, too.

I can confirm that when building in debug mode without compiler optimizations, the unit test fails without also applying ros#1651.

@meyerj meyerj force-pushed the fix_subscription_busy_wait-melodic branch from f7308e6 to d84ecc1 Compare June 18, 2019 18:05
@cwecht cwecht force-pushed the fix_subscription_busy_wait-melodic branch from 3db1254 to 52dfdb1 Compare February 15, 2020 16:26
@cwecht cwecht force-pushed the fix_subscription_busy_wait-melodic branch from 749246e to 1ae22ec Compare July 30, 2020 17:46
Replace duplicate wait_for() call in CallbackQueue::callOne() with a loop and a call to wait_until().
…ely if timeout.isZero()

... and if none of the other result conditions holds (i.e. the queue is Empty or Disabled).
@dirk-thomas
Copy link

I created ros#2014 to run CI for this change and be able to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants