diff options
author | John Reck <jreck@google.com> | 2015-11-10 12:52:44 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2015-11-10 13:41:32 -0800 |
commit | cba287b9716155183faf21865a6c28ba49ffe486 (patch) | |
tree | 90e2be92f6fe3298f3cb289e5cbc1cb3afcb61d7 /libs/hwui/renderthread/RenderThread.cpp | |
parent | 8382f98f6246c514106ca2bd88ab9f3c8d2ff5c8 (diff) |
Fix threading issues
Bug: 25584167
Change-Id: I413ef9e0c86f7cca1f7d085e0071745ca0192853
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.cpp')
-rw-r--r-- | libs/hwui/renderthread/RenderThread.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 526a84861d98..9fb30c928c00 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -25,7 +25,9 @@ #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <sys/resource.h> +#include <utils/Condition.h> #include <utils/Log.h> +#include <utils/Mutex.h> namespace android { namespace uirenderer { @@ -325,10 +327,16 @@ void RenderThread::queue(RenderTask* task) { } void RenderThread::queueAndWait(RenderTask* task) { - SignalingRenderTask syncTask(task, &mSyncMutex, &mSyncCondition); - AutoMutex _lock(mSyncMutex); + // These need to be local to the thread to avoid the Condition + // signaling the wrong thread. The easiest way to achieve that is to just + // make this on the stack, although that has a slight cost to it + Mutex mutex; + Condition condition; + SignalingRenderTask syncTask(task, &mutex, &condition); + + AutoMutex _lock(mutex); queue(&syncTask); - mSyncCondition.wait(mSyncMutex); + condition.wait(mutex); } void RenderThread::queueAtFront(RenderTask* task) { |