mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed a bug handling queued analytics events after a failed server connection attempt
This commit is contained in:
parent
040a3168f3
commit
b2f32a712f
1 changed files with 14 additions and 10 deletions
|
|
@ -89,20 +89,24 @@ void ThreadedAnalyticsDestination::EventDispatcher::run()
|
|||
|
||||
while (! threadShouldExit())
|
||||
{
|
||||
auto eventsToSendCapacity = maxBatchSize - eventsToSend.size();
|
||||
|
||||
if (eventsToSendCapacity > 0)
|
||||
{
|
||||
const ScopedLock lock (queueAccess);
|
||||
const auto numEventsInBatch = eventsToSend.size();
|
||||
const auto freeBatchCapacity = maxBatchSize - numEventsInBatch;
|
||||
|
||||
const auto numEventsInQueue = (int) eventQueue.size();
|
||||
|
||||
if (numEventsInQueue > 0)
|
||||
if (freeBatchCapacity > 0)
|
||||
{
|
||||
const auto numEventsToAdd = jmin (eventsToSendCapacity, numEventsInQueue);
|
||||
const auto numNewEvents = (int) eventQueue.size() - numEventsInBatch;
|
||||
|
||||
for (size_t i = 0; i < (size_t) numEventsToAdd; ++i)
|
||||
eventsToSend.add (eventQueue[i]);
|
||||
if (numNewEvents > 0)
|
||||
{
|
||||
const ScopedLock lock (queueAccess);
|
||||
|
||||
const auto numEventsToAdd = jmin (numNewEvents, freeBatchCapacity);
|
||||
const auto newBatchSize = numEventsInBatch + numEventsToAdd;
|
||||
|
||||
for (size_t i = numEventsInBatch; i < (size_t) newBatchSize; ++i)
|
||||
eventsToSend.add (eventQueue[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue