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

Fixes IgnMonitor bug. #759

Merged

Conversation

francocipollone
Copy link
Collaborator

Related to #751

IgnMonitor class subscribes a callback method to a topic.
Ignition-transport7 doesn't guarantee that the callback method is executed while the instance of the class is still alive.
The callback method being called after the instance was destroyed used to happen randomly in CI when stressed.

To solve that lack of synchronization we introduce a std::share_ptr of the IgnMonitor class into the callback method.

See #751 for further information.

Copy link
Collaborator

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

PTAL

test/regression/cpp/test_utilities/helpers.h Outdated Show resolved Hide resolved
test/regression/cpp/test_utilities/helpers.h Outdated Show resolved Hide resolved
test/regression/cpp/test_utilities/helpers.h Outdated Show resolved Hide resolved
test/regression/cpp/test_utilities/helpers.h Outdated Show resolved Hide resolved
test/regression/cpp/test_utilities/helpers.h Show resolved Hide resolved
test/regression/cpp/agent_simulation_builder_test.cc Outdated Show resolved Hide resolved
Copy link
Collaborator

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

PTAL

test/regression/cpp/test_utilities/helpers.h Show resolved Hide resolved
// Ignition subscriber callback, updating state
// and notify all threads waiting on this instance.
//
// @param message Message received.
void OnTopicMessage(const IGN_TYPE& message) {
// A std::shared_ptr to `this` is created in order to guarantee
// that the IgnMonitor instance isn't destroyed for
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't --> hasn't been already
for --> at

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

test/regression/cpp/test_utilities/helpers.h Outdated Show resolved Hide resolved
agalbachicar
agalbachicar previously approved these changes Mar 5, 2021
Copy link
Collaborator

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

LGTM!!

// @param A pointer to this instance.
// @throws std::logic_error When `self_ptr.get()` != `this`.
void Initialize(std::shared_ptr<IgnMonitor<IGN_TYPE>> self_ptr) {
DELPHYNE_VALIDATE(self_ptr.get() == this, std::logic_error, "self_ptr must point at `this` instance.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: must point at --> must point to

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

agalbachicar
agalbachicar previously approved these changes Mar 5, 2021
@francocipollone
Copy link
Collaborator Author

Sorry @agalbachicar, I had to push again. No changes since the last review.

Copy link
Collaborator

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

LGTM

@francocipollone francocipollone merged commit b611dab into master Mar 5, 2021
@francocipollone francocipollone deleted the francocipollone/fix_agent_simulation_builder_test branch March 5, 2021 17:59
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