mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
- added more safety code arouind SDL threads in case we get failures from SDL itself
This commit is contained in:
@@ -29,11 +29,17 @@ Thread::Thread() {
|
|||||||
Thread::~Thread() {
|
Thread::~Thread() {
|
||||||
if(thread != NULL) {
|
if(thread != NULL) {
|
||||||
SDL_WaitThread(thread, NULL);
|
SDL_WaitThread(thread, NULL);
|
||||||
|
thread = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::start() {
|
void Thread::start() {
|
||||||
thread = SDL_CreateThread(beginExecution, this);
|
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) {
|
void Thread::setPriority(Thread::Priority threadPriority) {
|
||||||
@@ -44,7 +50,9 @@ int Thread::beginExecution(void* data) {
|
|||||||
Thread* thread = static_cast<Thread*> (data);
|
Thread* thread = static_cast<Thread*> (data);
|
||||||
assert(thread != NULL);
|
assert(thread != NULL);
|
||||||
if(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();
|
thread->execute();
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user