INNER CODE UNIT · Java
scheduleFlush
apache/dubbo · dubbo-common/src/main/java/org/apache/dubbo/common/BatchExecutorQueue.java:47
protected void scheduleFlush(Executor executor) {
if (scheduled.compareAndSet(false, true)) {
executor.execute(() -> this.run(executor));
}
}
private void run(Executor executor) {
try {
Queue<T> snapshot = new LinkedList<>();
T item;
while ((item = queue.poll()) != null) {
snapshot.add(item);
}
int i = 0;
boolean flushedOnce = false;
while ((item = snapshot.poll()) != null) {
if (snapshot.size() == 0) {
flushedOnce = false;