Skip to content

Commit e4fc80f

Browse files
authored
Merge pull request #201 from DataDog/vickenty/drain-loop
Avoid busy loop on client shutdown
2 parents ad4daea + 50ceb1b commit e4fc80f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/com/timgroup/statsd/StatsDProcessor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ protected void processLoop() {
9090
closeSignal.countDown();
9191
clientClosed = true;
9292
}
93+
if (clientClosed) {
94+
// We are draining highPrioMessages, which is a non-blocking
95+
// queue. Avoid a busy loop if the queue is empty while the aggregator
96+
// is flushing.
97+
Thread.sleep(WAIT_SLEEP_MS);
98+
}
9399
continue;
94100
}
95101

0 commit comments

Comments
 (0)