add LockMutex::Unlock
This commit is contained in:
@@ -79,10 +79,12 @@ LockMutex::LockMutex(RageMutex &mut, const char *file_, int line_):
|
|||||||
locked_at(RageTimer::GetTimeSinceStart())
|
locked_at(RageTimer::GetTimeSinceStart())
|
||||||
{
|
{
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
|
locked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LockMutex::~LockMutex()
|
LockMutex::~LockMutex()
|
||||||
{
|
{
|
||||||
|
if(locked)
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
|
|
||||||
if(file)
|
if(file)
|
||||||
@@ -93,6 +95,15 @@ LockMutex::~LockMutex()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LockMutex::Unlock()
|
||||||
|
{
|
||||||
|
ASSERT(locked);
|
||||||
|
locked = false;
|
||||||
|
|
||||||
|
mutex.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
File: RageThreads
|
File: RageThreads
|
||||||
|
|||||||
@@ -30,12 +30,17 @@ class LockMutex
|
|||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
float locked_at;
|
float locked_at;
|
||||||
|
bool locked;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LockMutex(RageMutex &mut, const char *file, int line);
|
LockMutex(RageMutex &mut, const char *file, int line);
|
||||||
LockMutex(RageMutex &mut): mutex(mut), file(NULL), line(-1), locked_at(0) { mutex.Lock(); }
|
LockMutex(RageMutex &mut): mutex(mut), file(NULL), line(-1), locked_at(0) { mutex.Lock(); }
|
||||||
~LockMutex();
|
~LockMutex();
|
||||||
LockMutex(LockMutex &cpy): mutex(cpy.mutex), file(cpy.file), line(cpy.line), locked_at(cpy.locked_at) { mutex.Lock(); }
|
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
|
/* Double-abstracting __LINE__ lets us append it to other text, to generate
|
||||||
|
|||||||
Reference in New Issue
Block a user