Avoid queue size race condition
This commit is contained in:
parent
96cd140c62
commit
ed6d7578a5
@ -392,6 +392,7 @@ void SFXManager::mainLoop(void *obj)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
bool empty_queue = me->m_sfx_commands.getData().empty();
|
||||||
ul.unlock();
|
ul.unlock();
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
PROFILER_PUSH_CPU_MARKER("Execute", 0, 255, 0);
|
PROFILER_PUSH_CPU_MARKER("Execute", 0, 255, 0);
|
||||||
@ -462,9 +463,7 @@ void SFXManager::mainLoop(void *obj)
|
|||||||
current = NULL;
|
current = NULL;
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
PROFILER_PUSH_CPU_MARKER("yield", 0, 0, 255);
|
PROFILER_PUSH_CPU_MARKER("yield", 0, 0, 255);
|
||||||
// We access the size without lock, doesn't matter if we
|
if (empty_queue && me->sfxAllowed())
|
||||||
// should get an incorrect value because of concurrent read/writes
|
|
||||||
if (me->m_sfx_commands.getData().size() == 0 && me->sfxAllowed())
|
|
||||||
{
|
{
|
||||||
// Wait some time to let other threads run, then queue an
|
// Wait some time to let other threads run, then queue an
|
||||||
// update event to keep music playing.
|
// update event to keep music playing.
|
||||||
|
Loading…
Reference in New Issue
Block a user