mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Switched global thread to love._curthread and made love.thread.getThread() return that
This commit is contained in:
@@ -276,6 +276,12 @@ namespace sdl
|
||||
|
||||
int w_getThread(lua_State *L)
|
||||
{
|
||||
if (lua_isnoneornil(L, 1))
|
||||
{
|
||||
lua_getglobal(L, "love");
|
||||
lua_getfield(L, -1, "_curthread");
|
||||
return 1;
|
||||
}
|
||||
std::string name = luaL_checkstring(L, 1);
|
||||
Thread *t = instance->getThread(name);
|
||||
if (t)
|
||||
@@ -311,6 +317,13 @@ namespace sdl
|
||||
try
|
||||
{
|
||||
instance = new ThreadModule();
|
||||
lua_getglobal(L, "love");
|
||||
Thread *curthread = instance->getThread("main");
|
||||
curthread->lock();
|
||||
curthread->retain();
|
||||
curthread->unlock();
|
||||
luax_newtype(L, "Thread", THREAD_THREAD_T, (void*)curthread);
|
||||
lua_setfield(L, -2, "_curthread");
|
||||
}
|
||||
catch(Exception & e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user