- attempt to improve issues in the custom menu related to freezing

- modified debug UI display to support multi levels of UI debug info
- added more validations to mutexes
- improved client sockets to properly be setup as non blocking
This commit is contained in:
Mark Vejvoda
2011-02-06 07:01:54 +00:00
parent 0380bcdb5d
commit c58e893047
11 changed files with 96 additions and 19 deletions

View File

@@ -77,8 +77,9 @@ void Thread::resume() {
// Mutex
// =====================================
Mutex::Mutex() {
Mutex::Mutex(string ownerId) {
refCount=0;
this->ownerId = ownerId;
mutex = SDL_CreateMutex();
assert(mutex != NULL);
if(mutex == NULL) {
@@ -91,9 +92,15 @@ Mutex::Mutex() {
Mutex::~Mutex() {
if(mutex == NULL) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__);
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
throw runtime_error(szBuf);
}
else if(refCount >= 1) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
throw runtime_error(szBuf);
}
SDL_DestroyMutex(mutex);
mutex=NULL;
}
@@ -101,7 +108,7 @@ Mutex::~Mutex() {
void Mutex::p() {
if(mutex == NULL) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__);
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
throw runtime_error(szBuf);
}
SDL_mutexP(mutex);
@@ -111,7 +118,7 @@ void Mutex::p() {
void Mutex::v() {
if(mutex == NULL) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__);
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
throw runtime_error(szBuf);
}
refCount--;