Added guards incase of multiple calls

This commit is contained in:
Kayne Ruse
2013-06-18 14:06:57 +10:00
parent fd65fec5f7
commit e833129983
+9
View File
@@ -32,6 +32,9 @@ static int networkQueue(void*) {
} }
void BeginQueueThread() { void BeginQueueThread() {
if (running) {
return;
}
running = true; running = true;
if (!(queueThread = SDL_CreateThread(networkQueue, nullptr))) { if (!(queueThread = SDL_CreateThread(networkQueue, nullptr))) {
throw(std::runtime_error("Failed to create the network thread")); throw(std::runtime_error("Failed to create the network thread"));
@@ -39,12 +42,18 @@ void BeginQueueThread() {
} }
void EndQueueThread() { void EndQueueThread() {
if (!running) {
return;
}
running = false; running = false;
SDL_WaitThread(queueThread, nullptr); SDL_WaitThread(queueThread, nullptr);
queueThread = nullptr; queueThread = nullptr;
} }
void KillQueueThread() { void KillQueueThread() {
if (!running) {
return;
}
running = false; running = false;
SDL_KillThread(queueThread); SDL_KillThread(queueThread);
queueThread = nullptr; queueThread = nullptr;