mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Updates.
This commit is contained in:
24
ScopedLock.h
24
ScopedLock.h
@@ -38,15 +38,33 @@ public:
|
|||||||
|
|
||||||
ScopedLock &operator=(const ScopedLock &sl)
|
ScopedLock &operator=(const ScopedLock &sl)
|
||||||
{ // we inherit any lock the other class member had
|
{ // we inherit any lock the other class member had
|
||||||
|
if(mMutex!=sl.mMutex)
|
||||||
|
{
|
||||||
if(mValid) mMutex->unlock();
|
if(mValid) mMutex->unlock();
|
||||||
mMutex=sl.mMutex;
|
mMutex=sl.mMutex;
|
||||||
if(sl.mValid)
|
mMutex->lock();
|
||||||
{
|
|
||||||
mValid=true;
|
mValid=true;
|
||||||
sl.mValid=false;
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unlock(void)
|
||||||
|
{
|
||||||
|
if(mValid)
|
||||||
|
{
|
||||||
|
mMutex->unlock();
|
||||||
|
mValid=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lock(void)
|
||||||
|
{
|
||||||
|
if(mValid)
|
||||||
|
{
|
||||||
|
mMutex->lock();
|
||||||
|
mValid=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user