Merge pull request #44 from defold/buffer-threading-fix

Fixed threading issue of checking if command buffer is empty
This commit is contained in:
Mathias Westerdahl
2021-09-07 14:34:35 +02:00
committed by GitHub

View File

@@ -121,13 +121,14 @@ void IAP_Queue_Push(IAPCommandQueue* queue, IAPCommand* cmd)
void IAP_Queue_Flush(IAPCommandQueue* queue, IAPCommandFn fn, void* ctx) void IAP_Queue_Flush(IAPCommandQueue* queue, IAPCommandFn fn, void* ctx)
{ {
assert(fn != 0); assert(fn != 0);
DM_MUTEX_SCOPED_LOCK(queue->m_Mutex);
if (queue->m_Commands.Empty()) if (queue->m_Commands.Empty())
{ {
return; return;
} }
DM_MUTEX_SCOPED_LOCK(queue->m_Mutex);
for(uint32_t i = 0; i != queue->m_Commands.Size(); ++i) for(uint32_t i = 0; i != queue->m_Commands.Size(); ++i)
{ {
fn(&queue->m_Commands[i], ctx); fn(&queue->m_Commands[i], ctx);