mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Improved thread safety of love.event.wait and love.event.push
This commit is contained in:
@@ -64,7 +64,7 @@ int w_poll(lua_State *L)
|
|||||||
|
|
||||||
int w_wait(lua_State *L)
|
int w_wait(lua_State *L)
|
||||||
{
|
{
|
||||||
static Message *m;
|
Message *m;
|
||||||
|
|
||||||
if ((m = instance->wait()))
|
if ((m = instance->wait()))
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ int w_wait(lua_State *L)
|
|||||||
|
|
||||||
int w_push(lua_State *L)
|
int w_push(lua_State *L)
|
||||||
{
|
{
|
||||||
static Message *m;
|
Message *m;
|
||||||
|
|
||||||
bool success = (m = Message::fromLua(L, 1)) != NULL;
|
bool success = (m = Message::fromLua(L, 1)) != NULL;
|
||||||
luax_pushboolean(L, success);
|
luax_pushboolean(L, success);
|
||||||
|
|||||||
@@ -55,22 +55,23 @@ EmptyLock::~EmptyLock()
|
|||||||
|
|
||||||
void EmptyLock::setLock(Mutex *m)
|
void EmptyLock::setLock(Mutex *m)
|
||||||
{
|
{
|
||||||
|
if (m)
|
||||||
|
m->lock();
|
||||||
|
|
||||||
if (mutex)
|
if (mutex)
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
|
|
||||||
mutex = m;
|
mutex = m;
|
||||||
|
|
||||||
if (mutex)
|
|
||||||
mutex->lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmptyLock::setLock(Mutex &m)
|
void EmptyLock::setLock(Mutex &m)
|
||||||
{
|
{
|
||||||
|
m.lock();
|
||||||
|
|
||||||
if (mutex)
|
if (mutex)
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
|
|
||||||
mutex = &m;
|
mutex = &m;
|
||||||
mutex->lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Threadable::Threadable()
|
Threadable::Threadable()
|
||||||
|
|||||||
Reference in New Issue
Block a user