Repository navigation
refactor(blocking): avoid PoisonError unwrap branches in parker - #458
Merged
Merged
Conversation
`blocking::parker` was the last module in `asyncband` calling `.unwrap()` directly on `std::sync::Mutex` and `std::sync::Condvar` instead of ignoring lock poisoning. Because `ParkerState::lock` protects no user state and only closes the notification window around `Condvar::wait`, those `Result::unwrap` calls emitted unreachable `PoisonError` formatting and unwinding branches in `ParkerState::park` and `ParkerState::unpark`.
Switch `ParkerState::lock` to `crate::internal::mutex::Mutex<()>` and recover the guard with `PoisonError::into_inner` on `Condvar::{wait, wait_timeout}` to match the rest of the crate.
Signed-off-by: tison <wander4096@gmail.com>
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.
Summary
blocking::parkerwas the last module inasyncbandcalling.unwrap()directly onstd::sync::Mutexandstd::sync::Condvarinstead of ignoring lock poisoning. BecauseParkerState::lockprotects no user state and only closes the notification window aroundCondvar::wait, thoseResult::unwrapcalls emitted unreachablePoisonErrorformatting and unwinding branches inParkerState::parkandParkerState::unpark(shrinking both compiled functions by ~14.5% onaarch64).Switch
ParkerState::locktocrate::internal::mutex::Mutex<()>and recover the guard withPoisonError::into_inneronCondvar::{wait, wait_timeout}to match the rest of the crate.