mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Merge branch 'main' into 12.0-development
This commit is contained in:
@@ -379,6 +379,13 @@ function love.init()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The first couple event pumps on some systems (e.g. macOS) can take a
|
||||||
|
-- while. We'd rather hit that slowdown here than in event processing
|
||||||
|
-- within the first frames.
|
||||||
|
if love.event then
|
||||||
|
for i = 1, 2 do love.event.pump() end
|
||||||
|
end
|
||||||
|
|
||||||
-- Our first timestep, because window creation can take some time
|
-- Our first timestep, because window creation can take some time
|
||||||
if love.timer then
|
if love.timer then
|
||||||
love.timer.step()
|
love.timer.step()
|
||||||
|
|||||||
@@ -48,13 +48,24 @@ bool Thread::start()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
|
|
||||||
if (running)
|
if (running)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (thread) // Clean old handle up
|
if (thread) // Clean old handle up
|
||||||
SDL_WaitThread(thread, nullptr);
|
SDL_WaitThread(thread, nullptr);
|
||||||
|
|
||||||
|
// Keep the threadable around until the thread is done with it.
|
||||||
|
// This is done before thread_runner executes because there can be a delay
|
||||||
|
// between CreateThread and the start of the thread code's execution.
|
||||||
|
t->retain();
|
||||||
|
|
||||||
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
||||||
running = (thread != nullptr);
|
running = (thread != nullptr);
|
||||||
|
|
||||||
|
if (!running)
|
||||||
|
t->release(); // thread_runner is never called in this situation.
|
||||||
|
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +91,6 @@ bool Thread::isRunning()
|
|||||||
int Thread::thread_runner(void *data)
|
int Thread::thread_runner(void *data)
|
||||||
{
|
{
|
||||||
Thread *self = (Thread *) data; // some compilers don't like 'this'
|
Thread *self = (Thread *) data; // some compilers don't like 'this'
|
||||||
self->t->retain();
|
|
||||||
|
|
||||||
self->t->threadFunction();
|
self->t->threadFunction();
|
||||||
|
|
||||||
@@ -89,6 +99,7 @@ int Thread::thread_runner(void *data)
|
|||||||
self->running = false;
|
self->running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This was retained in start().
|
||||||
self->t->release();
|
self->t->release();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user