Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion castle/src/main/java/io/castle/android/queue/EventQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class EventQueue implements Callback<Void> {
private ObjectQueue<Event> eventObjectQueue;

private Call<Void> flushCall;
private boolean flushOngoing = false;
private int flushCount;

private ExecutorService executor;
Expand Down Expand Up @@ -111,6 +112,7 @@ private synchronized void trim() throws IOException {
public synchronized void flush() {
CastleLogger.d("EventQueue size " + eventObjectQueue.size());
if (!isFlushing() && (!eventObjectQueue.isEmpty())) {
flushOngoing = true;
executor.execute(() -> {
try {
trim();
Expand Down Expand Up @@ -163,7 +165,7 @@ public synchronized void flush() {
}

public synchronized boolean isFlushing() {
return flushCall != null;
return flushOngoing;
}

public synchronized boolean needsFlush() {
Expand All @@ -172,6 +174,7 @@ public synchronized boolean needsFlush() {

private synchronized void flushed() {
flushCall = null;
flushOngoing = false;
flushCount = 0;
}

Expand Down