diff options
| author | bors <bors@rust-lang.org> | 2020-04-24 23:36:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-04-24 23:36:52 +0000 |
| commit | 40008dcb494a00571123b7d59115068a200ebe34 (patch) | |
| tree | 2fd39a8435e3a41236e0820e08646e9e7a1508ea /src/libstd/sync | |
| parent | 3360cc3a0ea33c84d0b0b1163107b1c1acbf2a69 (diff) | |
| parent | 32fb77d9516ec8d781b998e5d314dc7b6a7954d8 (diff) | |
| download | rust-40008dcb494a00571123b7d59115068a200ebe34.tar.gz rust-40008dcb494a00571123b7d59115068a200ebe34.zip | |
Auto merge of #71539 - Dylan-DPC:rollup-a2vbfh9, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #69456 (fix misleading type annotation diagonstics) - #71330 (Only run dataflow for const qualification if type-based check would fail) - #71480 (Improve PanicInfo examples readability) - #71485 (Add BinaryHeap::retain as suggested in #42849) - #71512 (Remove useless "" args) - #71527 (Miscellaneous cleanup in `check_consts`) - #71534 (Avoid unused Option::map results) - #71535 (Fix typos in docs for keyword "in") Failed merges: r? @ghost
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(); + } } } |
