Merge pull request #253 from tcolgate/eventrace

Event queue processes and filling race.
This commit is contained in:
Matthias Rampke 2019-07-25 15:11:02 +02:00 committed by GitHub
commit 353b38c80b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,6 +82,7 @@ func newEventQueue(c chan Events, flushThreshold int, flushInterval time.Duratio
c: c,
flushThreshold: flushThreshold,
flushTicker: ticker,
q: make([]Event, 0, flushThreshold),
}
go func() {
for {
@ -112,7 +113,7 @@ func (eq *eventQueue) flush() {
func (eq *eventQueue) flushUnlocked() {
eq.c <- eq.q
eq.q = eq.q[:0]
eq.q = make([]Event, 0, cap(eq.q))
eventsFlushed.Inc()
}