code: func (l *Logger) consume() {
  	go func() {
  		// Process the single next task in sequence until completion,
  		// then consume the next task.
  		for task := range l.tasks {
  			l.logTask(task)
  		}
  	}()
  
  	defer close(l.tasks)
  
  	pending := make([]Task, 0)
  
  	for {
  		// If there is a pending task, "peek" it off of the set of
  		// pending tasks.
  		var next Task
  		if len(pending) > 0 {
  			next = pending[0]
  		}
  
  		if next == nil {
  			// If there was no pending task, wait for either a)
  			// l.queue to close, or b) a new task to be submitted.
  			task, ok := <-l.queue
  			if !ok {
  				// If the queue is closed, no more new tasks may
  				// be added.
  				return
  			}
  
  			// Otherwise, add a new task to the set of tasks to
  			// process immediately, since there is no current
  			// buffer.
  			l.tasks <- task
  		} else {
  			// If there is a pending task, wait for either a) a
  			// write to process the task to become non-blocking, or
  			// b) a new task to enter the queue.
  			select {
  			case task, ok := <-l.queue:
  				if !ok {
  					// If the queue is closed, no more tasks
  					// may be added.
  					return
  				}
  				// Otherwise, add the next task to the set of
  				// pending, active tasks.
  				pending = append(pending, task)
  			case l.tasks <- next:
  				// Or "pop" the peeked task off of the pending
  				// set.
  				pending = pending[1:]
  			}
  		}
  	}
  }
docs: // consume creates a pseudo-infinte buffer between the incoming set of tasks and
  // the queue of tasks to work on.