forked from mirrors/statsd_exporter
Merge pull request #253 from tcolgate/eventrace
Event queue processes and filling race.
This commit is contained in:
commit
353b38c80b
1 changed files with 2 additions and 1 deletions
3
event.go
3
event.go
|
@ -82,6 +82,7 @@ func newEventQueue(c chan Events, flushThreshold int, flushInterval time.Duratio
|
||||||
c: c,
|
c: c,
|
||||||
flushThreshold: flushThreshold,
|
flushThreshold: flushThreshold,
|
||||||
flushTicker: ticker,
|
flushTicker: ticker,
|
||||||
|
q: make([]Event, 0, flushThreshold),
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
@ -112,7 +113,7 @@ func (eq *eventQueue) flush() {
|
||||||
|
|
||||||
func (eq *eventQueue) flushUnlocked() {
|
func (eq *eventQueue) flushUnlocked() {
|
||||||
eq.c <- eq.q
|
eq.c <- eq.q
|
||||||
eq.q = eq.q[:0]
|
eq.q = make([]Event, 0, cap(eq.q))
|
||||||
eventsFlushed.Inc()
|
eventsFlushed.Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue