diff src/modules/thread/LuaThread.cpp @ 1304:ee1448bb9680 minor

Fix race conditions and deadlocks in Channels (hopefully) (issue #554) Also, this is a giant commit because of the official Code Style (tm) was applied.
author Bart van Strien <bart.bes+projects@gmail.com>
date Wed, 30 Jan 2013 17:15:12 +0100
parents a74672ba1320
children 4ae1deb94765
line wrap: on
line diff
--- a/src/modules/thread/LuaThread.cpp	Sun Jan 27 20:04:16 2013 +0100
+++ b/src/modules/thread/LuaThread.cpp	Wed Jan 30 17:15:12 2013 +0100
@@ -30,39 +30,39 @@
 {
 namespace thread
 {
-	LuaThread::LuaThread(const std::string &name, love::Data *code)
-		: name(name), code(code)
-	{
-		code->retain();
-	}
+LuaThread::LuaThread(const std::string &name, love::Data *code)
+	: name(name), code(code)
+{
+	code->retain();
+}
 
-	LuaThread::~LuaThread()
-	{
-		code->release();
-	}
+LuaThread::~LuaThread()
+{
+	code->release();
+}
 
-	void LuaThread::threadFunction()
-	{
-		this->retain();
-		lua_State * L = lua_open();
-		luaL_openlibs(L);
-	#ifdef LOVE_BUILD_STANDALONE
-		love::luax_preload(L, luaopen_love, "love");
-		luaopen_love(L);
-	#endif // LOVE_BUILD_STANDALONE
-		luaopen_love_thread(L);
-		if (luaL_loadbuffer(L, (const char*) code->getData(), code->getSize(), name.c_str()) != 0)
+void LuaThread::threadFunction()
+{
+	this->retain();
+	lua_State * L = lua_open();
+	luaL_openlibs(L);
+#ifdef LOVE_BUILD_STANDALONE
+	love::luax_preload(L, luaopen_love, "love");
+	luaopen_love(L);
+#endif // LOVE_BUILD_STANDALONE
+	luaopen_love_thread(L);
+	if (luaL_loadbuffer(L, (const char *) code->getData(), code->getSize(), name.c_str()) != 0)
+		error = luax_tostring(L, -1);
+	else
+		if (lua_pcall(L, 0, 0, 0) != 0)
 			error = luax_tostring(L, -1);
-		else
-			if (lua_pcall(L, 0, 0, 0) != 0)
-				error = luax_tostring(L, -1);
-		lua_close(L);
-		this->release();
-	}
+	lua_close(L);
+	this->release();
+}
 
-	const std::string &LuaThread::getError()
-	{
-		return error;
-	}
+const std::string &LuaThread::getError()
+{
+	return error;
+}
 } // thread
 } // love