Fix the race condition issue of RenderOnce() in GlWindow.
If RenderOnce() function is called in event thread continuously,
the race condition issue will be occured.
Because the renderOnce flag is written in event thread
and the flag is read and written in render thread without lock.
This patch is to fix the issue.
Change-Id: I0a45c0e538c19b9c552d75fd1cf1e2ca4cbd042a
void GlWindowRenderThread::RenderOnce()
{
+ // Most of all, this function is called in event thread
ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
mRequestRenderOnce = 1;
mRenderThreadWaitCondition.Notify(lock);
}
TimeService::SleepUntil(timeToSleepUntil);
-
- if(mRequestRenderOnce)
- {
- mRequestRenderOnce = 0;
- }
}
if(mGLTerminateCallback)
mRenderThreadWaitCondition.Wait(updateLock);
}
+ mRequestRenderOnce = 0;
// Keep the update-render thread alive if this thread is NOT to be destroyed
return !mDestroyRenderThread;
}