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.

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2013-01-30 17:15:12 +01:00
parent be2363fc00
commit c7c5d0ed6b
15 changed files with 414 additions and 367 deletions
+30 -30
View File
@@ -30,39 +30,39 @@ namespace love
{
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