code: func (q *TransferQueue) collectPendingUntil(done <-chan struct{}) (pending batch, closing bool) {
  	for {
  		select {
  		case t, ok := <-q.incoming:
  			if !ok {
  				closing = true
  				<-done
  				return
  			}
  
  			pending = append(pending, t)
  		case <-done:
  			return
  		}
  	}
  }
docs: // collectPendingUntil collects items from q.incoming into a "pending" batch
  // until the given "done" channel is written to, or is closed.
  //
  // A "pending" batch is returned, along with whether or not "q.incoming" is
  // closed.