diff options
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mpsc/shared.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/sync.rs | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index c4e929624d7..fd9d61e99c2 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -91,7 +91,7 @@ impl<T> Packet<T> { // // This can only be called at channel-creation time pub fn inherit_blocker(&self, token: Option<SignalToken>, guard: MutexGuard<'_, ()>) { - token.map(|token| { + if let Some(token) = token { assert_eq!(self.cnt.load(Ordering::SeqCst), 0); assert_eq!(self.to_wake.load(Ordering::SeqCst), 0); self.to_wake.store(unsafe { token.cast_to_usize() }, Ordering::SeqCst); @@ -118,7 +118,7 @@ impl<T> Packet<T> { unsafe { *self.steals.get() = -1; } - }); + } // When the shared packet is constructed, we grabbed this lock. The // purpose of this lock is to ensure that abort_selection() doesn't diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 3e2050799cc..79123903e92 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -343,8 +343,12 @@ impl<T> Packet<T> { mem::drop(guard); // only outside of the lock do we wake up the pending threads - pending_sender1.map(|t| t.signal()); - pending_sender2.map(|t| t.signal()); + if let Some(token) = pending_sender1 { + token.signal(); + } + if let Some(token) = pending_sender2 { + token.signal(); + } } // Prepares this shared packet for a channel clone, essentially just bumping @@ -410,7 +414,9 @@ impl<T> Packet<T> { while let Some(token) = queue.dequeue() { token.signal(); } - waiter.map(|t| t.signal()); + if let Some(token) = waiter { + token.signal(); + } } } |
