Mercurial > gemma
comparison pkg/misc/scheduler.go @ 1519:08e1b38a4a8b
Be aware of canceling the last scheduled function.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 06 Dec 2018 14:34:03 +0100 |
parents | 43a32358a016 |
children |
comparison
equal
deleted
inserted
replaced
1518:cff2cf1f3038 | 1519:08e1b38a4a8b |
---|---|
128 } | 128 } |
129 | 129 |
130 case k := <-s.cancel: | 130 case k := <-s.cancel: |
131 for i := len(s.queue) - 1; i >= 0; { | 131 for i := len(s.queue) - 1; i >= 0; { |
132 if s.queue[i].kind == k { | 132 if s.queue[i].kind == k { |
133 copy(s.queue[i:], s.queue[i+1:]) | 133 n := len(s.queue) - 1 |
134 s.queue[len(s.queue)-1] = nil | 134 if i < n { |
135 s.queue = s.queue[:len(s.queue)-1] | 135 copy(s.queue[i:], s.queue[i+1:]) |
136 } | |
137 s.queue[n] = nil | |
138 s.queue = s.queue[:n] | |
136 } | 139 } |
137 } | 140 } |
138 heap.Init(&s.queue) | 141 heap.Init(&s.queue) |
139 } | 142 } |
140 } | 143 } |