Commits

Alex Szpakowski committed d48cdb8

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

  • Participants
  • Parent commits 7d78309

Comments (0)

Files changed (2)

File src/modules/event/sdl/wrap_Event.cpp

 
 int w_wait(lua_State *L)
 {
-	static Message *m;
+	Message *m;
 
 	if ((m = instance->wait()))
 	{
 
 int w_push(lua_State *L)
 {
-	static Message *m;
+	Message *m;
 
 	bool success = (m = Message::fromLua(L, 1)) != NULL;
 	luax_pushboolean(L, success);

File src/modules/thread/threads.cpp

 
 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()