message: Use wait_while for Condvar in Queue to simplify code.
diff: use std::collections::VecDeque;
  use std::sync::{Condvar, Mutex};
  -use std::time::{Duration, Instant};
  +use std::time::Duration;
  /// A simple, threadsafe, queue of items of type `T`
  ///
  @@ -40,35 +40,23 @@ impl<T> Queue<T> {
  /// Pushes an item onto the queue, blocking if the queue is full.
  pub fn push_bounded(&self, item: T) {
  - let mut state = self.state.lock().unwrap();
  - loop {
  - if state.items.len() >= self.bound {
  - state = self.bounded_cv.wait(state).unwrap();
  - } else {
  + let locked_state = self.state.lock().unwrap();
  + let mut state = self
  + .bounded_cv
  + .wait_while(locked_state, |s| s.items.len() >= self.bound)
  + .unwrap();
  state.items.push_back(item);
  self.popper_cv.notify_one();
  - break;
  - }
  - }
  }
  pub fn pop(&self, timeout: Duration) -> Option<T> {
  - let mut state = self.state.lock().unwrap();
  - let now = Instant::now();
  - while state.items.is_empty() {
  - let elapsed = now.elapsed();
  - if elapsed >= timeout {
  - break;
  - }
  - let (lock, result) = self
  + let (mut state, result) = self
  .popper_cv
  - .wait_timeout(state, timeout - elapsed)
  + .wait_timeout_while(self.state.lock().unwrap(), timeout, |s| s.items.is_empty())
  .unwrap();
  - state = lock;
  if result.timed_out() {
  - break;
  - }
  - }
  + None
  + } else {
  let value = state.items.pop_front()?;
  if state.items.len() < self.bound {
  // Assumes threads cannot be canceled.
  @@ -76,6 +64,7 @@ impl<T> Queue<T> {
  }
  Some(value)
  }
  + }
  pub fn try_pop_all(&self) -> Vec<T> {
  let mut state = self.state.lock().unwrap();
  