2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-02-05 09:36:53 +00:00

Use sync.WaitGroup for shutdown

This commit is contained in:
Ken Hibino
2020-02-15 23:14:30 -08:00
parent 2bcaea52ce
commit 3d9a222bb3
11 changed files with 51 additions and 18 deletions

View File

@@ -119,11 +119,13 @@ func (p *processor) terminate() {
p.restore() // move any unfinished tasks back to the queue.
}
func (p *processor) start() {
func (p *processor) start(wg *sync.WaitGroup) {
// NOTE: The call to "restore" needs to complete before starting
// the processor goroutine.
p.restore()
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-p.done: