code: func queueHandler(in <-chan interface{}, out chan<- interface{}, quit <-chan struct{}) {
  	var q []interface{}
  	var dequeue chan<- interface{}
  	skipQueue := out
  	var next interface{}
  out:
  	for {
  		select {
  		case n, ok := <-in:
  			if !ok {
  				// Sender closed input channel.
  				break out
  			}
  
  			// Either send to out immediately if skipQueue is
  			// non-nil (queue is empty) and reader is ready,
  			// or append to the queue and send later.
  			select {
  			case skipQueue <- n:
  			default:
  				q = append(q, n)
  				dequeue = out
  				skipQueue = nil
  				next = q[0]
  			}
  
  		case dequeue <- next:
  			copy(q, q[1:])
  			q[len(q)-1] = nil // avoid leak
  			q = q[:len(q)-1]
  			if len(q) == 0 {
  				dequeue = nil
  				skipQueue = out
  			} else {
  				next = q[0]
  			}
  
  		case <-quit:
  			break out
  		}
  	}
  	close(out)
  }
docs: // queueHandler manages a queue of empty interfaces, reading from in and
  // sending the oldest unsent to out.  This handler stops when either of the
  // in or quit channels are closed, and closes out before returning, without
  // waiting to send any variables still remaining in the queue.