mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Use SDL_DetachThread instead of a conditional SDL_WaitThread when a Thread is destroyed.
This commit is contained in:
@@ -35,13 +35,9 @@ Thread::Thread(Threadable *t)
|
|||||||
|
|
||||||
Thread::~Thread()
|
Thread::~Thread()
|
||||||
{
|
{
|
||||||
if (!running) // Clean up handle
|
// Clean up handle
|
||||||
wait();
|
if (thread)
|
||||||
/*
|
SDL_DetachThread(thread);
|
||||||
if (running)
|
|
||||||
wait();
|
|
||||||
FIXME: Needed for proper thread cleanup
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thread::start()
|
bool Thread::start()
|
||||||
@@ -50,9 +46,9 @@ bool Thread::start()
|
|||||||
if (running)
|
if (running)
|
||||||
return false;
|
return false;
|
||||||
if (thread) // Clean old handle up
|
if (thread) // Clean old handle up
|
||||||
SDL_WaitThread(thread, 0);
|
SDL_WaitThread(thread, nullptr);
|
||||||
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
||||||
running = (thread != 0);
|
running = (thread != nullptr);
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,10 +59,10 @@ void Thread::wait()
|
|||||||
if (!thread)
|
if (!thread)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_WaitThread(thread, 0);
|
SDL_WaitThread(thread, nullptr);
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
running = false;
|
running = false;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thread::isRunning()
|
bool Thread::isRunning()
|
||||||
|
|||||||
Reference in New Issue
Block a user