Stop stops any further events from being processed by the EventQueue. Any event which is currently being processed by the EventQueue will continue to run. All other events waiting to be processed, and all events that may be enqueued will not be processed by the event queue; they will be cancelled. I
()
| 262 | // enqueued will not be processed by the event queue; they will be cancelled. |
| 263 | // If the queue has already been stopped, this is a no-op. |
| 264 | func (q *EventQueue) Stop() { |
| 265 | if q.notSafeToAccess() { |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | q.closeOnce.Do(func() { |
| 270 | q.logger.Debug("stopping EventQueue") |
| 271 | // Any event that is sent to the queue at this point will be cancelled |
| 272 | // immediately in Enqueue(). |
| 273 | close(q.drain) |
| 274 | |
| 275 | // Signal that the queue has been drained. |
| 276 | close(q.close) |
| 277 | |
| 278 | q.eventsMu.Lock() |
| 279 | close(q.events) |
| 280 | q.eventsMu.Unlock() |
| 281 | }) |
| 282 | } |
| 283 | |
| 284 | // WaitToBeDrained returns the channel which waits for the EventQueue to have been |
| 285 | // stopped. This allows for queuers to ensure that all events in the queue have |