Fixed the bug

running was false when it was checked in networkQueue(), so the thread was
ending early.
This commit is contained in:
Kayne Ruse
2013-06-17 15:49:57 +10:00
parent 685ca94335
commit ea761fb5bb
+1 -4
View File
@@ -7,7 +7,6 @@
#include <stdexcept> #include <stdexcept>
#include <deque> #include <deque>
#include <iostream>
static SDL_sem* lock = SDL_CreateSemaphore(1); static SDL_sem* lock = SDL_CreateSemaphore(1);
static SDL_Thread* queueThread = nullptr; static SDL_Thread* queueThread = nullptr;
@@ -18,8 +17,6 @@ static bool running = false;
static int networkQueue(void*) { static int networkQueue(void*) {
UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get(); UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get();
//this line is the fix for the quirk
// std::cout << "thread running" << std::endl;
while(running) { while(running) {
SDL_SemWait(lock); SDL_SemWait(lock);
while(netUtil->Receive()) { while(netUtil->Receive()) {
@@ -34,10 +31,10 @@ static int networkQueue(void*) {
} }
void BeginQueueThread() { void BeginQueueThread() {
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"));
} }
running = true;
} }
void EndQueueThread() { void EndQueueThread() {