Exit worker threads immediately when their input channels disconnect#5
Merged
DerFetzer merged 1 commit intoDerFetzer:mainfrom Feb 6, 2025
Merged
Conversation
This stops the worker threads from sitting in a tight busy loop consuming 100% CPU if the channels they listen for input on are ever dropped. This can for example happen if the thread owning the sender panics. Even if the panic does result in the process eventually aborting, this stops the worker threads to go crazy while the shut down happens.
Owner
|
Thank you very much! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This stops the worker threads from sitting in a tight busy loop consuming 100% CPU if the channels they listen for input on are ever dropped.
This can for example happen if the thread owning the sender panics. Even if the panic does result in the process eventually aborting, this stops the worker threads from going crazy while the shut down happens.
I tested this by inserting a panic in the main thread. And indeed, the camera thread were doing a few thousand loops before the process died. This way should be more efficient and cleaner.
The diff is 99% indentation changes only. The only real change is that the
loop+if letwas joined into awhile let. And then alog::debug!was added at the end of bothrunmethods.