I created an EventStore interface, and an InMemoryEventStore implementation. I moved the two event buffer queues from Emitter into InMemoryEventStore.
The Emitter previously had a thread (bufferConsumer) with two functions: transferring events from the first queue into the eventsToSend queue, and then checking the size of eventsToSend against bufferSize to see if there was a whole batch's worth of events yet. I moved the first part of this functionality into a bufferConsumer thread in InMemoryEventStore. The size checking stayed in Emitter, but the thread is now called areThereEventsToSend.
I also found the queue names eventsBuffer and eventsToSend confusing, since many Emitter methods referred to buffer but meant eventsToSend. I renamed them eventInitialBuffer and eventStagingBuffer. There're still some places where it would be good to get more clarity. In the Android tracker, which uses an SQLite database, instead of "initialBuffer" there's eventWaitingList. But that is an actual (Array)List.
Currently the InMemoryEventStore bufferConsumer thread can't be stopped.
Also I have accidentally included some changes in Tracker! I was initially playing around with stuff for a different Issue.
I created an EventStore interface, and an InMemoryEventStore implementation. I moved the two event buffer queues from Emitter into InMemoryEventStore.
The Emitter previously had a thread (
bufferConsumer
) with two functions: transferring events from the first queue into theeventsToSend
queue, and then checking the size ofeventsToSend
againstbufferSize
to see if there was a whole batch's worth of events yet. I moved the first part of this functionality into abufferConsumer
thread in InMemoryEventStore. The size checking stayed in Emitter, but the thread is now calledareThereEventsToSend
.I also found the queue names
eventsBuffer
andeventsToSend
confusing, since many Emitter methods referred to buffer but meanteventsToSend
. I renamed themeventInitialBuffer
andeventStagingBuffer
. There're still some places where it would be good to get more clarity. In the Android tracker, which uses an SQLite database, instead of "initialBuffer" there'seventWaitingList
. But that is an actual (Array)List.Currently the InMemoryEventStore bufferConsumer thread can't be stopped.
Also I have accidentally included some changes in Tracker! I was initially playing around with stuff for a different Issue.