(timeout time.Duration)
| 214 | } |
| 215 | |
| 216 | func (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 |
nothing calls this directly
no test coverage detected