MCPcopy Create free account
hub / github.com/flant/shell-operator / WaitStopWithTimeout

Method WaitStopWithTimeout

pkg/task/queue/queue_set.go:216–244  ·  view source on GitHub ↗
(timeout time.Duration)

Source from the content-addressed store, hash-verified

214}
215
216func (tqs *TaskQueueSet) WaitStopWithTimeout(timeout time.Duration) {
217 checkTick := time.NewTicker(time.Millisecond * 100)
218 defer checkTick.Stop()
219
220 timeoutTick := time.NewTicker(timeout)
221 defer timeoutTick.Stop()
222
223 for {
224 select {
225 case <-checkTick.C:
226 stopped := func() bool {
227 for _, q := range tqs.Queues.List() {
228 if q.GetStatusType() != QueueStatusStop {
229 return false
230 }
231 }
232
233 return true
234 }()
235
236 if stopped {
237 return
238 }
239
240 case <-timeoutTick.C:
241 return
242 }
243 }
244}
245
246// Shutdown stops every queue in the set and blocks until either all workers
247// reach QueueStatusStop or ctx is canceled / deadlines. Returns ctx.Err() on

Callers

nothing calls this directly

Calls 3

GetStatusTypeMethod · 0.80
StopMethod · 0.65
ListMethod · 0.45

Tested by

no test coverage detected