mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user