diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2020-09-25 18:38:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-25 08:38:13 -0700 |
commit | 444660664b96f758610a0e7201a6a1a31a0f2405 (patch) | |
tree | 0b6829c695a5a0e2cec1157f84ecbe10a0780a3c /tokio/src/runtime/queue.rs | |
parent | cf025ba45f68934ae2138bb75ee2a5ee50506d1b (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/runtime/queue.rs')
-rw-r--r-- | tokio/src/runtime/queue.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/runtime/queue.rs b/tokio/src/runtime/queue.rs index c654514b..cdf4009c 100644 --- a/tokio/src/runtime/queue.rs +++ b/tokio/src/runtime/queue.rs @@ -481,7 +481,7 @@ impl<T: 'static> Inject<T> { /// Close the injection queue, returns `true` if the queue is open when the /// transition is made. pub(super) fn close(&self) -> bool { - let mut p = self.pointers.lock().unwrap(); + let mut p = self.pointers.lock(); if p.is_closed { return false; @@ -492,7 +492,7 @@ impl<T: 'static> Inject<T> { } pub(super) fn is_closed(&self) -> bool { - self.pointers.lock().unwrap().is_closed + self.pointers.lock().is_closed } pub(super) fn len(&self) -> usize { @@ -502,7 +502,7 @@ impl<T: 'static> Inject<T> { /// Pushes a value into the queue. pub(super) fn push(&self, task: task::Notified<T>) { // Acquire queue lock - let mut p = self.pointers.lock().unwrap(); + let mut p = self.pointers.lock(); if p.is_closed { // Drop the mutex to avoid a potential deadlock when @@ -541,7 +541,7 @@ impl<T: 'static> Inject<T> { debug_assert!(get_next(batch_tail).is_none()); - let mut p = self.pointers.lock().unwrap(); + let mut p = self.pointers.lock(); if let Some(tail) = p.tail { set_next(tail, Some(batch_head)); @@ -566,7 +566,7 @@ impl<T: 'static> Inject<T> { return None; } - let mut p = self.pointers.lock().unwrap(); + let mut p = self.pointers.lock(); // It is possible to hit null here if another thread poped the last // task between us checking `len` and acquiring the lock. |