Thanks to visit codestin.com
Credit goes to github.com

Skip to content

spin independent thread for RemoteControl #224

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

Conversation

v4hn
Copy link
Contributor

@v4hn v4hn commented Aug 25, 2022

The RemoteControl class currently spins the global queue when waiting for the user to confirm.
It does so because the node handle for the subscriber that receives the feedback is usually initialized with the global callback queue. But that also means that other callbacks (including the one currently running!) can be processed in the thread that is waiting for user input and it's easy to block all available spinners or get into recursive spin calls for the same topic.

Even worse, there is no workaround: Even if the user provides a node handle with a different callback queue, the calls to spinOnce will not even process that queue but the method calls still invoke unwanted side-effects without serving any purpose.

Thus I modified the class to create its own spinner unconditionally.

@jspricke @tylerjw

@auto-assign auto-assign bot requested a review from davetcoleman August 25, 2022 09:38
@codecov
Copy link

codecov bot commented Aug 25, 2022

Codecov Report

Merging #224 (364460a) into master (9b10fd2) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #224      +/-   ##
==========================================
- Coverage   19.83%   19.81%   -0.03%     
==========================================
  Files           5        5              
  Lines        1699     1701       +2     
==========================================
  Hits          337      337              
- Misses       1362     1364       +2     
Impacted Files Coverage Δ
src/remote_control.cpp 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Avoid deadlocks and cross-thread effects with other callbacks.
@tamspr2 tamspr2 force-pushed the pr-master-no-spin-global-remote-control branch from 1ca5497 to 364460a Compare August 25, 2022 09:46
@v4hn
Copy link
Contributor Author

v4hn commented Aug 25, 2022

Added a commit to imitate @jspricke's approach in #193 which does not rely on a new thread.
There's really no need for a whole thread for this (even though it doesn't harm a lot either).

Edit: Removed that commit again. As we also want to stop autonomous mode we actually need the spinner here.

@tamspr2 tamspr2 force-pushed the pr-master-no-spin-global-remote-control branch from f39b6fa to 364460a Compare August 25, 2022 11:51
@tylerjw tylerjw merged commit a0875b6 into PickNikRobotics:master Aug 25, 2022
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