Browse Source

Fixed a data race in ThreadedAnalyticsDestination

v6.1.6
Tom Poole 4 years ago
parent
commit
60d52182bb
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      modules/juce_analytics/destinations/juce_ThreadedAnalyticsDestination.cpp

+ 2
- 2
modules/juce_analytics/destinations/juce_ThreadedAnalyticsDestination.cpp View File

@@ -89,6 +89,8 @@ void ThreadedAnalyticsDestination::EventDispatcher::run()
while (! threadShouldExit()) while (! threadShouldExit())
{ {
{ {
const ScopedLock lock (queueAccess);
const auto numEventsInBatch = eventsToSend.size(); const auto numEventsInBatch = eventsToSend.size();
const auto freeBatchCapacity = maxBatchSize - numEventsInBatch; const auto freeBatchCapacity = maxBatchSize - numEventsInBatch;
@@ -98,8 +100,6 @@ void ThreadedAnalyticsDestination::EventDispatcher::run()
if (numNewEvents > 0) if (numNewEvents > 0)
{ {
const ScopedLock lock (queueAccess);
const auto numEventsToAdd = jmin (numNewEvents, freeBatchCapacity); const auto numEventsToAdd = jmin (numNewEvents, freeBatchCapacity);
const auto newBatchSize = numEventsInBatch + numEventsToAdd; const auto newBatchSize = numEventsInBatch + numEventsToAdd;


Loading…
Cancel
Save