Improved thread safety of love.event.wait and love.event.push

This commit is contained in:
Alex Szpakowski
2013-08-30 17:34:58 -03:00
parent 4584cf6780
commit d3826aba9d
2 changed files with 7 additions and 6 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ int w_poll(lua_State *L)
int w_wait(lua_State *L)
{
static Message *m;
Message *m;
if ((m = instance->wait()))
{
@@ -78,7 +78,7 @@ int w_wait(lua_State *L)
int w_push(lua_State *L)
{
static Message *m;
Message *m;
bool success = (m = Message::fromLua(L, 1)) != NULL;
luax_pushboolean(L, success);
+5 -4
View File
@@ -55,22 +55,23 @@ EmptyLock::~EmptyLock()
void EmptyLock::setLock(Mutex *m)
{
if (m)
m->lock();
if (mutex)
mutex->unlock();
mutex = m;
if (mutex)
mutex->lock();
}
void EmptyLock::setLock(Mutex &m)
{
m.lock();
if (mutex)
mutex->unlock();
mutex = &m;
mutex->lock();
}
Threadable::Threadable()