(f func())
| 58 | } |
| 59 | |
| 60 | func (q *ExecQueue) run(f func()) { |
| 61 | f() |
| 62 | |
| 63 | q.mu.Lock() |
| 64 | for len(q.queue) > 0 && !q.closed { |
| 65 | f := q.queue[0] |
| 66 | q.queue[0] = nil |
| 67 | q.queue = q.queue[1:] |
| 68 | q.mu.Unlock() |
| 69 | f() |
| 70 | q.mu.Lock() |
| 71 | } |
| 72 | q.inFlight = false |
| 73 | q.queue = nil |
| 74 | if q.doneWaiter != nil { |
| 75 | close(q.doneWaiter) |
| 76 | q.doneWaiter = nil |
| 77 | } |
| 78 | q.mu.Unlock() |
| 79 | } |
| 80 | |
| 81 | // Shutdown asynchronously signals the queue to stop. |
| 82 | func (q *ExecQueue) Shutdown() { |