miner: use channels instead of atomics in update loop (#21536)

This PR changes several different things:

- Adds test cases for the miner loop
- Stops the worker if it wasn't already stopped in worker.Close()
- Uses channels instead of atomics in the miner.update() loop

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Marius van der Wijden
2020-09-10 19:27:42 +02:00
committed by GitHub
parent d7f02b448a
commit 7cf56d6f06
3 changed files with 196 additions and 32 deletions

View File

@ -303,6 +303,7 @@ func (w *worker) isRunning() bool {
// close terminates all background threads maintained by the worker.
// Note the worker does not support being closed multiple times.
func (w *worker) close() {
atomic.StoreInt32(&w.running, 0)
close(w.exitCh)
}