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

Add hasStarted() const to Timer API #1464

Merged
merged 1 commit into from
Aug 3, 2018

Conversation

bmagyar
Copy link
Contributor

@bmagyar bmagyar commented Jul 24, 2018

To assert if a timer is running at the moment, one can hack their way around by using isValid and setDuration to invalid ones.

I'm proposing the addition of a simple const accessor to the internal started_ field.

Should I add a simple test file as well?
Can this be cherry-picked to kinetic-devel too?

@mikepurvis
Copy link
Member

LGTM— have wanted this in the past. Slight preference for isStarted over hasStarted, as there are many more "bool isXYZ()" methods in roscpp. However, the timer already has hasPending anyway, so it doesn't really matter.

Either way, 👍

@bmagyar
Copy link
Contributor Author

bmagyar commented Jul 25, 2018

I am open to changing that. I was a little reluctant to add the const declaration to the function. Although that feels like the correct thing to do, I saw that the current API doesn't have any. Changing it would be breaking API (in the strict sense) so I didn't want to touch anything else.

@bmagyar
Copy link
Contributor Author

bmagyar commented Jul 25, 2018

@clalancette could we get a rebuild//rerun of tests on Debian Stretch?

@clalancette
Copy link
Contributor

@ros-pull-request-builder retest this please

@mikepurvis
Copy link
Member

mikepurvis commented Jul 25, 2018

Adding const should always be safe, shouldn't it?

REP9 does list "changing the const/volatile qualifiers of a member function" as a thing that causes ABI breakage, but that is surprising to me— my impression is that constness is enforced at compilation time, and is basically invisible to the linker. Apparently not.

@bmagyar
Copy link
Contributor Author

bmagyar commented Jul 25, 2018

The const modifier changes the signature of a function, which even causes API breaks AFAIK.

@mikepurvis
Copy link
Member

mikepurvis commented Jul 25, 2018

It might be an ABI break, but it's definitely not an API break— it's making the method more permissive than previously, since it was previously only callable on non-const instances of the class, but is now callable on const instances as well. So there's no existing usage which will break at compile time by making a method const.

@bmagyar
Copy link
Contributor Author

bmagyar commented Jul 25, 2018 via email

@bmagyar
Copy link
Contributor Author

bmagyar commented Aug 1, 2018

@clalancette could you please point us to someone who could review/merge this?

@dirk-thomas
Copy link
Member

Thank you for the improvement.

@dirk-thomas dirk-thomas merged commit 772a138 into ros:melodic-devel Aug 3, 2018
@bmagyar
Copy link
Contributor Author

bmagyar commented Aug 10, 2018

@tfoote can we cherry-pick this to Kinetic too?

@dirk-thomas
Copy link
Member

The new API is currently not selected for backporting into Lunar (see #1477). As such it wouldn't be backported to Kinetic (since that happens from the Lunar branch).

Commonly we don't backport new features. If you think this would be very important (and can't be worked around in user code) please comment on the referenced ticket to request it being backported to Lunar.

dirk-thomas pushed a commit that referenced this pull request Aug 13, 2018
dirk-thomas pushed a commit that referenced this pull request Aug 20, 2018
meyerj added a commit to meyerj/ros_comm that referenced this pull request Dec 6, 2018
…lTimer and ros::SteadyTimer

ros::Timer::hasStarted() has been added in ros#1464. The same member function should exist in the other
two timer implementations, too, for completeness.
meyerj added a commit to meyerj/ros_comm that referenced this pull request Dec 14, 2018
…lTimer and ros::SteadyTimer

ros::Timer::hasStarted() has been added in ros#1464. The same member function should exist in the other
two timer implementations, too, for completeness.
@dirk-thomas
Copy link
Member

FYI #1541.

meyerj added a commit to meyerj/ros_comm that referenced this pull request Jan 31, 2019
…lTimer and ros::SteadyTimer

ros::Timer::hasStarted() has been added in ros#1464. The same member function should exist in the other
two timer implementations, too, for completeness.
dirk-thomas pushed a commit that referenced this pull request Jan 31, 2019
* roscpp: copy hasStarted() member function from ros::Timer to ros::WallTimer and ros::SteadyTimer

ros::Timer::hasStarted() has been added in #1464. The same member function should exist in the other
two timer implementations, too, for completeness.

* Check for nullptr in WallTimer::hasStarted() and SteadyTimer::hasStarted()

Analogous to fe9479c (#1541).
tahsinkose pushed a commit to tahsinkose/ros_comm that referenced this pull request Apr 15, 2019
* roscpp: copy hasStarted() member function from ros::Timer to ros::WallTimer and ros::SteadyTimer

ros::Timer::hasStarted() has been added in ros#1464. The same member function should exist in the other
two timer implementations, too, for completeness.

* Check for nullptr in WallTimer::hasStarted() and SteadyTimer::hasStarted()

Analogous to fe9479c (ros#1541).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants