diff options
Diffstat (limited to 'src/libstd/sync/mpsc')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/spsc_queue.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/stream.rs | 9 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/sync.rs | 12 |
4 files changed, 12 insertions, 24 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index c37c0405bbb..8c5cec969a6 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -397,7 +397,7 @@ enum Flavor<T> { #[doc(hidden)] trait UnsafeFlavor<T> { - fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>; + fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>>; unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> { &mut *self.inner_unsafe().get() } @@ -406,12 +406,12 @@ trait UnsafeFlavor<T> { } } impl<T> UnsafeFlavor<T> for Sender<T> { - fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> { + fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>> { &self.inner } } impl<T> UnsafeFlavor<T> for Receiver<T> { - fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> { + fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>> { &self.inner } } @@ -677,7 +677,7 @@ impl<T> SyncSender<T> { impl<T> Clone for SyncSender<T> { fn clone(&self) -> SyncSender<T> { unsafe { (*self.inner.get()).clone_chan(); } - return SyncSender::new(self.inner.clone()); + SyncSender::new(self.inner.clone()) } } diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 819f75c006b..ffd33f8518f 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -196,7 +196,7 @@ impl<T> Queue<T> { let _: Box<Node<T>> = Box::from_raw(tail); } } - return ret; + ret } } @@ -207,14 +207,13 @@ impl<T> Queue<T> { /// The reference returned is invalid if it is not used before the consumer /// pops the value off the queue. If the producer then pushes another value /// onto the queue, it will overwrite the value pointed to by the reference. - pub fn peek<'a>(&'a self) -> Option<&'a mut T> { + pub fn peek(&self) -> Option<&mut T> { // This is essentially the same as above with all the popping bits // stripped out. unsafe { let tail = *self.tail.get(); let next = (*tail).next.load(Ordering::Acquire); - if next.is_null() { return None } - return (*next).value.as_mut(); + if next.is_null() { None } else { (*next).value.as_mut() } } } } diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs index a9da1b12f7d..e8012ca470b 100644 --- a/src/libstd/sync/mpsc/stream.rs +++ b/src/libstd/sync/mpsc/stream.rs @@ -307,12 +307,7 @@ impl<T> Packet<T> { steals, DISCONNECTED, Ordering::SeqCst); cnt != DISCONNECTED && cnt != steals } { - loop { - match self.queue.pop() { - Some(..) => { steals += 1; } - None => break - } - } + while let Some(_) = self.queue.pop() { steals += 1; } } // At this point in time, we have gated all future senders from sending, @@ -378,7 +373,7 @@ impl<T> Packet<T> { // previous value is positive because we're not going to sleep let prev = self.bump(1); assert!(prev == DISCONNECTED || prev >= 0); - return ret; + ret } } } diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 84d758cf9b3..b98fc2859af 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -254,7 +254,7 @@ impl<T> Packet<T> { assert!(guard.buf.size() > 0); let ret = guard.buf.dequeue(); self.wakeup_senders(waited, guard); - return Ok(ret); + Ok(ret) } pub fn try_recv(&self) -> Result<T, Failure> { @@ -267,8 +267,7 @@ impl<T> Packet<T> { // Be sure to wake up neighbors let ret = Ok(guard.buf.dequeue()); self.wakeup_senders(false, guard); - - return ret; + ret } // Wake up pending senders after some data has been received @@ -356,12 +355,7 @@ impl<T> Packet<T> { }; mem::drop(guard); - loop { - match queue.dequeue() { - Some(token) => { token.signal(); } - None => break, - } - } + while let Some(token) = queue.dequeue() { token.signal(); } waiter.map(|t| t.signal()); } |
