- added more safety code arouind SDL threads in case we get failures from SDL itself

This commit is contained in:
Mark Vejvoda 2010-08-27 03:40:54 +00:00
parent 0504ea3b97
commit f7d9cd50a6
1 changed files with 9 additions and 1 deletions

View File

@ -29,11 +29,17 @@ Thread::Thread() {
Thread::~Thread() {
if(thread != NULL) {
SDL_WaitThread(thread, NULL);
thread = NULL;
}
}
void Thread::start() {
thread = SDL_CreateThread(beginExecution, this);
if(thread == NULL) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] thread == NULL",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
}
}
void Thread::setPriority(Thread::Priority threadPriority) {
@ -44,7 +50,9 @@ int Thread::beginExecution(void* data) {
Thread* thread = static_cast<Thread*> (data);
assert(thread != NULL);
if(thread == NULL) {
throw runtime_error("thread == NULL");
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] thread == NULL",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
}
thread->execute();
return 0;