mirror of
https://github.com/glest/glest-source.git
synced 2025-09-29 08:59:01 +02:00
- added safe mutex wrapper class
This commit is contained in:
@@ -51,7 +51,7 @@ private:
|
||||
// class Mutex
|
||||
// =====================================================
|
||||
|
||||
class Mutex{
|
||||
class Mutex {
|
||||
private:
|
||||
SDL_mutex* mutex;
|
||||
|
||||
@@ -62,6 +62,28 @@ public:
|
||||
void v();
|
||||
};
|
||||
|
||||
class MutexSafeWrapper {
|
||||
protected:
|
||||
Mutex *mutex;
|
||||
public:
|
||||
|
||||
MutexSafeWrapper(Mutex *mutex) {
|
||||
this->mutex = mutex;
|
||||
if(this->mutex != NULL) {
|
||||
this->mutex->p();
|
||||
}
|
||||
}
|
||||
~MutexSafeWrapper() {
|
||||
ReleaseLock();
|
||||
}
|
||||
void ReleaseLock() {
|
||||
if(this->mutex != NULL) {
|
||||
this->mutex->v();
|
||||
this->mutex = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Semaphore
|
||||
// =====================================================
|
||||
|
Reference in New Issue
Block a user