Added guards incase of multiple calls
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user