Commit ae518eb0 by Greg Hartman Committed by Nicolas Capens

Add a mutex around SyncSet operations

BUG: 31072273 Change-Id: I037505ad3ab1ba80aecab4e24ec8d1932df2dcf7 Reviewed-on: https://swiftshader-review.googlesource.com/7030Reviewed-by: 's avatarLingfeng Yang <lfy@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarLingfeng Yang <lfy@google.com>
parent 8b27574a
......@@ -40,6 +40,22 @@
#include <vector>
#include <map>
class Guard
{
public:
explicit Guard(sw::BackoffLock* in) : mMutex(in)
{
mMutex->lock();
}
~Guard()
{
mMutex->unlock();
}
protected:
sw::BackoffLock* mMutex;
};
namespace egl
{
......@@ -453,9 +469,8 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
EGLSyncKHR Display::createSync(Context *context)
{
FenceSync *fenceSync = new egl::FenceSync(context);
Guard lk(&mSyncSetMutex);
mSyncSet.insert(fenceSync);
return fenceSync;
}
......@@ -490,8 +505,10 @@ void Display::destroyContext(egl::Context *context)
void Display::destroySync(FenceSync *sync)
{
mSyncSet.erase(sync);
{
Guard lk(&mSyncSetMutex);
mSyncSet.erase(sync);
}
delete sync;
}
......@@ -566,6 +583,7 @@ bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
bool Display::isValidSync(FenceSync *sync)
{
Guard lk(&mSyncSetMutex);
return mSyncSet.find(sync) != mSyncSet.end();
}
......
......@@ -20,6 +20,7 @@
#define INCLUDE_DISPLAY_H_
#include "Config.h"
#include "Common/MutexLock.hpp"
#include "Sync.hpp"
#include "common/NameSpace.hpp"
......@@ -91,6 +92,7 @@ namespace egl
ContextSet mContextSet;
typedef std::set<FenceSync*> SyncSet;
sw::BackoffLock mSyncSetMutex;
SyncSet mSyncSet;
gl::NameSpace<Image> mSharedImageNameSpace;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment