add LockMutex::Unlock
This commit is contained in:
@@ -79,11 +79,13 @@ LockMutex::LockMutex(RageMutex &mut, const char *file_, int line_):
|
||||
locked_at(RageTimer::GetTimeSinceStart())
|
||||
{
|
||||
mutex.Lock();
|
||||
locked = true;
|
||||
}
|
||||
|
||||
LockMutex::~LockMutex()
|
||||
{
|
||||
mutex.Unlock();
|
||||
if(locked)
|
||||
mutex.Unlock();
|
||||
|
||||
if(file)
|
||||
{
|
||||
@@ -93,6 +95,15 @@ LockMutex::~LockMutex()
|
||||
}
|
||||
}
|
||||
|
||||
void LockMutex::Unlock()
|
||||
{
|
||||
ASSERT(locked);
|
||||
locked = false;
|
||||
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: RageThreads
|
||||
|
||||
@@ -30,12 +30,17 @@ class LockMutex
|
||||
const char *file;
|
||||
int line;
|
||||
float locked_at;
|
||||
bool locked;
|
||||
|
||||
public:
|
||||
LockMutex(RageMutex &mut, const char *file, int line);
|
||||
LockMutex(RageMutex &mut): mutex(mut), file(NULL), line(-1), locked_at(0) { mutex.Lock(); }
|
||||
~LockMutex();
|
||||
LockMutex(LockMutex &cpy): mutex(cpy.mutex), file(cpy.file), line(cpy.line), locked_at(cpy.locked_at) { mutex.Lock(); }
|
||||
|
||||
/* Unlock the mutex (before this would normally go out of scope). This can
|
||||
* only be called once. */
|
||||
void Unlock();
|
||||
};
|
||||
|
||||
/* Double-abstracting __LINE__ lets us append it to other text, to generate
|
||||
|
||||
Reference in New Issue
Block a user