-
Notifications
You must be signed in to change notification settings - Fork 240
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 transactional state mutex for RecorderImpl class. #1547
Add transactional state mutex for RecorderImpl class. #1547
Conversation
@MichaelOrlov minor fix, could you take a look when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fujitatomoya Thanks for your contribution.
I have a few nitpick findings and suggestions and also have a concern about using recursive_mutex for protecting state transition.
I don't see a reason or rationale for protecting discovery start/stop operations with mutex at all. After some analysis, I came to the conclusion it would be enough to have an atomic stop_discovery_
variable.
I don't see possibilities for race conditions or undefined behavior in discovery start/stop operations even if it would be a public API and could be called from different threads.
If you agree please remove mutex lock in stop_discovery()
method and use regular non-recursive mutex for the state_transition_mutex_
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelOrlov sorry, i did not send this to you. cached for like a week in my browser... 😓
016b530
to
8a67807
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelOrlov thanks for the fix, lgtm with green CI.
Signed-off-by: Tomoya.Fujita <tomoya.fujita825@gmail.com>
Signed-off-by: Tomoya.Fujita <tomoya.fujita825@gmail.com>
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
- Also use non-recursive mutex for the `state_transition_mutex_` Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
- Removed mutex lock in pause(), resume() and toggle_paused() methods and use only atomic value change for `paused_` variable. - Renamed `state_transition_mutex_` to the `start_stop_transition_mutex_`. - Add unit test for `toggle_paused()` Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
d788074
to
337be35
Compare
- Changed type of the paused_ to the std::atomic_uchar Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
@fujitatomoya There is a warning for my "hacky" cast part in the
Unfortunately, I was not able to find a way how to fix this warning in a good way without changing the type of the I've tried to change the type to the |
Gist: https://gist.githubusercontent.com/MichaelOrlov/5f018e1125c75305282285cfd52d9352/raw/6c7bfb3b37e6ad32d4e0d2a521a41a02f5364390/ros2.repos |
@MichaelOrlov green light, we are good to go. |
@MichaelOrlov thanks for the help! |
@fujitatomoya Likewise! 😉 |
address #1529 (comment)