added mutex protection in custom game menu to protect access to member variables to avoid crashes when background thread and user changes both occur

This commit is contained in:
Mark Vejvoda
2010-06-04 21:46:10 +00:00
parent 052b82541f
commit 2970e5114a
4 changed files with 54 additions and 12 deletions

View File

@@ -69,17 +69,23 @@ public:
MutexSafeWrapper(Mutex *mutex) {
this->mutex = mutex;
if(this->mutex != NULL) {
this->mutex->p();
}
Lock();
}
~MutexSafeWrapper() {
ReleaseLock();
}
void ReleaseLock() {
void Lock() {
if(this->mutex != NULL) {
this->mutex->p();
}
}
void ReleaseLock(bool keepMutex=false) {
if(this->mutex != NULL) {
this->mutex->v();
this->mutex = NULL;
if(keepMutex == false) {
this->mutex = NULL;
}
}
}
};