1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a data race in ThreadedAnalyticsDestination

This commit is contained in:
Tom Poole 2021-03-25 18:24:11 +00:00
parent 2367d648f4
commit 60d52182bb

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;