Skip to content

Make more of the Waitable API abstract#2593

Merged
clalancette merged 2 commits intorollingfrom
clalancette/fix-waitable-api
Aug 2, 2024
Merged

Make more of the Waitable API abstract#2593
clalancette merged 2 commits intorollingfrom
clalancette/fix-waitable-api

Conversation

@clalancette
Copy link
Copy Markdown
Contributor

@clalancette clalancette commented Jul 31, 2024

I initially started looking at this because clang was complaining
that "all paths through this function will call itself" (see https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/1966/clang/new/fileName.-934007317/). And it
is correct; if an implementation does not override these methods,
and they are ever called, they will go into an infinite loop
calling themselves.

However, while looking at it it seemed to me that these were really
part of the API that a concrete implementation of Waitable needed
to implement. It is fine if an implementation doesn't want to do
anything (like the tests), but all of the "real" users in the codebase
override these.

Thus, remove the implementations here and make these pure virtual
functions that all subclasses must implement.

Note that I've split this into two commits for a particular reason. 5b3f59e is the one that will fix the clang warning. But while I was looking at it, I noticed that there are some other methods in there that really should be pure virtual. So commit 0194fb7 isn't required, but I think it is better C++.

This also requires ros2/system_tests#548 to go in at the same time.

I initially started looking at this because clang was complaining
that "all paths through this function will call itself".  And it
is correct; if an implementation does not override these methods,
and they are every called, they will go into an infinite loop
calling themselves.

However, while looking at it it seemed to me that these were really
part of the API that a concrete implementation of Waitable needed
to implement.  It is fine if an implementation doesn't want to do
anything (like the tests), but all of the "real" users in the codebase
override these.

Thus, remove the implementations here and make these pure virtual
functions that all subclasses must implement.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
In particular, these are implementations in the Waitable
class that only throw exceptions.  Rather than do this,
make these APIs pure virtual so all downstream classes
have to implement them.  All of the current users (except
for tests) do anyway, and it makes the API much cleaner.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette
Copy link
Copy Markdown
Contributor Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status
  • Clang Build Status

@clalancette
Copy link
Copy Markdown
Contributor Author

clalancette commented Aug 1, 2024

New CI after fixing the system tests:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status
  • Clang Build Status

@clalancette
Copy link
Copy Markdown
Contributor Author

New CI after responding to feedback in ros2/system_tests#548:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status
  • Clang Build Status

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with green CI

@fujitatomoya
Copy link
Copy Markdown
Collaborator

@clalancette windows failures seem unrelated, just in case can you take a look?

@clalancette
Copy link
Copy Markdown
Contributor Author

The only failure here is on Clang, and there, this PR improves things. With that, I'm going to go ahead and merge in both this one and ros2/system_tests#548 . Thanks for the reviews!

@clalancette clalancette merged commit c468967 into rolling Aug 2, 2024
@clalancette clalancette deleted the clalancette/fix-waitable-api branch August 2, 2024 12:01
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.

3 participants