summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/notify.rs
diff options
context:
space:
mode:
authorZahari Dichev <zaharidichev@gmail.com>2020-09-25 18:38:13 +0300
committerGitHub <noreply@github.com>2020-09-25 08:38:13 -0700
commit444660664b96f758610a0e7201a6a1a31a0f2405 (patch)
tree0b6829c695a5a0e2cec1157f84ecbe10a0780a3c /tokio/src/sync/notify.rs
parentcf025ba45f68934ae2138bb75ee2a5ee50506d1b (diff)
chore: handle std `Mutex` poisoning in a shim (#2872)
As tokio does not rely on poisoning, we can avoid always unwrapping when locking by handling the `PoisonError` in the Mutex shim. Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Diffstat (limited to 'tokio/src/sync/notify.rs')
-rw-r--r--tokio/src/sync/notify.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/sync/notify.rs b/tokio/src/sync/notify.rs
index d319e8aa..17117bfe 100644
--- a/tokio/src/sync/notify.rs
+++ b/tokio/src/sync/notify.rs
@@ -306,7 +306,7 @@ impl Notify {
}
// There are waiters, the lock must be acquired to notify.
- let mut waiters = self.waiters.lock().unwrap();
+ let mut waiters = self.waiters.lock();
// The state must be reloaded while the lock is held. The state may only
// transition out of WAITING while the lock is held.
@@ -321,7 +321,7 @@ impl Notify {
/// Notifies all waiting tasks
pub(crate) fn notify_waiters(&self) {
// There are waiters, the lock must be acquired to notify.
- let mut waiters = self.waiters.lock().unwrap();
+ let mut waiters = self.waiters.lock();
// The state must be reloaded while the lock is held. The state may only
// transition out of WAITING while the lock is held.
@@ -452,7 +452,7 @@ impl Future for Notified<'_> {
// Acquire the lock and attempt to transition to the waiting
// state.
- let mut waiters = notify.waiters.lock().unwrap();
+ let mut waiters = notify.waiters.lock();
// Reload the state with the lock held
let mut curr = notify.state.load(SeqCst);
@@ -516,7 +516,7 @@ impl Future for Notified<'_> {
// `notify.waiters`). In order to access the waker fields,
// we must hold the lock.
- let waiters = notify.waiters.lock().unwrap();
+ let waiters = notify.waiters.lock();
// Safety: called while locked
let w = unsafe { &mut *waiter.get() };
@@ -564,7 +564,7 @@ impl Drop for Notified<'_> {
// longer stored in the linked list.
if let Waiting = *state {
let mut notify_state = WAITING;
- let mut waiters = notify.waiters.lock().unwrap();
+ let mut waiters = notify.waiters.lock();
// `Notify.state` may be in any of the three states (Empty, Waiting,
// Notified). It doesn't actually matter what the atomic is set to