code: func (t *ProgressEmitter) Serve() {
  	var lastUpdate time.Time
  	var lastCount, newCount int
  	for {
  		select {
  		case <-t.stop:
  			l.Debugln("progress emitter: stopping")
  			return
  		case <-t.timer.C:
  			t.mut.Lock()
  			l.Debugln("progress emitter: timer - looking after", len(t.registry))
  
  			newLastUpdated := lastUpdate
  			newCount = t.lenRegistryLocked()
  			for _, pullers := range t.registry {
  				for _, puller := range pullers {
  					if updated := puller.Updated(); updated.After(newLastUpdated) {
  						newLastUpdated = updated
  					}
  				}
  			}
  
  			if !newLastUpdated.Equal(lastUpdate) || newCount != lastCount {
  				lastUpdate = newLastUpdated
  				lastCount = newCount
  				t.sendDownloadProgressEventLocked()
  				if len(t.connections) > 0 {
  					t.sendDownloadProgressMessagesLocked()
  				}
  			} else {
  				l.Debugln("progress emitter: nothing new")
  			}
  
  			if newCount != 0 {
  				t.timer.Reset(t.interval)
  			}
  			t.mut.Unlock()
  		}
  	}
  }
docs: // Serve starts the progress emitter which starts emitting DownloadProgress
  // events as the progress happens.