code: func (m *CPUMiner) miningWorkerController() {
  	// launchWorkers groups common code to launch a specified number of
  	// workers for generating blocks.
  	var runningWorkers []chan struct{}
  	launchWorkers := func(numWorkers uint32) {
  		for i := uint32(0); i < numWorkers; i++ {
  			quit := make(chan struct{})
  			runningWorkers = append(runningWorkers, quit)
  
  			m.workerWg.Add(1)
  			go m.generateBlocks(quit)
  		}
  	}
  
  	// Launch the current number of workers by default.
  	runningWorkers = make([]chan struct{}, 0, m.numWorkers)
  	launchWorkers(m.numWorkers)
  
  out:
  	for {
  		select {
  		// Update the number of running workers.
  		case <-m.updateNumWorkers:
  			// No change.
  			numRunning := uint32(len(runningWorkers))
  			if m.numWorkers == numRunning {
  				continue
  			}
  
  			// Add new workers.
  			if m.numWorkers > numRunning {
  				launchWorkers(m.numWorkers - numRunning)
  				continue
  			}
  
  			// Signal the most recently created goroutines to exit.
  			for i := numRunning - 1; i >= m.numWorkers; i-- {
  				close(runningWorkers[i])
  				runningWorkers[i] = nil
  				runningWorkers = runningWorkers[:i]
  			}
  
  		case <-m.quit:
  			for _, quit := range runningWorkers {
  				close(quit)
  			}
  			break out
  		}
  	}
  
  	// Wait until all workers shut down to stop the speed monitor since
  	// they rely on being able to send updates to it.
  	m.workerWg.Wait()
  	close(m.speedMonitorQuit)
  	m.wg.Done()
  }
docs: // miningWorkerController launches the worker goroutines that are used to
  // generate block templates and solve them.  It also provides the ability to
  // dynamically adjust the number of running worker goroutines.
  //
  // It must be run as a goroutine.