Skip to content

Commit

Permalink
Do not lock mutex every frame
Browse files Browse the repository at this point in the history
  • Loading branch information
AGulev committed Sep 25, 2019
1 parent ba8e7c8 commit 27c5753
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions extension-iac/src/iac_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int IAC_PlatformSetListener(lua_State* L)

static void QueueCommand(Command* cmd)
{
dmMutex::ScopedLock lk(g_IAC.m_Mutex);
DM_MUTEX_SCOPED_LOCK(g_IAC.m_Mutex);
if (g_IAC.m_CmdQueue.Full())
{
g_IAC.m_CmdQueue.OffsetCapacity(8);
Expand Down Expand Up @@ -295,7 +295,13 @@ dmExtension::Result FinalizeIAC(dmExtension::Params* params)

dmExtension::Result UpdateIAC(dmExtension::Params* params)
{
dmMutex::ScopedLock lk(g_IAC.m_Mutex);
if (g_IAC.m_CmdQueue.Empty())
{
return dmExtension::RESULT_OK;
}

DM_MUTEX_SCOPED_LOCK(g_IAC.m_Mutex);

for (uint32_t i=0;i!=g_IAC.m_CmdQueue.Size();i++)
{
Command& cmd = g_IAC.m_CmdQueue[i];
Expand All @@ -318,16 +324,17 @@ dmExtension::Result UpdateIAC(dmExtension::Params* params)
}
if (cmd.m_Payload != 0x0)
{
free((void*)cmd.m_Payload);
free(cmd.m_Payload);
cmd.m_Payload = 0x0;
}
if (cmd.m_Origin != 0x0)
{
free((void*)cmd.m_Origin);
free(cmd.m_Origin);
cmd.m_Origin = 0x0;
}
}
g_IAC.m_CmdQueue.SetSize(0);

return dmExtension::RESULT_OK;
}

Expand Down

0 comments on commit 27c5753

Please sign in to comment.