Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Add hasStarted() const to Timer API - #1464

Merged
dirk-thomas merged 1 commit into
ros:melodic-develfrom
bmagyar:extend_timer_api
Aug 3, 2018
Merged

dirk-thomas merged 1 commit into
ros:melodic-develfrom
bmagyar:extend_timer_api

Conversation

@bmagyar

@bmagyar bmagyar commented Jul 24, 2018 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

bmagyar commented Jul 25, 2018

Copy link
Copy Markdown
Contributor Author

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

bmagyar commented Jul 25, 2018

Copy link
Copy Markdown
Contributor Author

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

@clalancette

Copy link
Copy Markdown
Contributor

@ros-pull-request-builder retest this please

@mikepurvis

mikepurvis commented Jul 25, 2018 •

Copy link
Copy Markdown
Member

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

bmagyar commented Jul 25, 2018

Copy link
Copy Markdown
Contributor Author

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

@mikepurvis

mikepurvis commented Jul 25, 2018 •

Copy link
Copy Markdown
Member

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

bmagyar commented Jul 25, 2018 via email •

Copy link
Copy Markdown
Contributor Author

@bmagyar

bmagyar commented Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

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

@dirk-thomas

Copy link
Copy Markdown
Member

Thank you for the improvement.

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

bmagyar commented Aug 10, 2018

Copy link
Copy Markdown
Contributor Author

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

@dirk-thomas

Copy link
Copy Markdown
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
Copy Markdown
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).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants