int Lua_RegisterTimedEvent(lua_State * L) //in this case, L == lu { const char * funcName = strdup(luaL_checkstring(L,1)); int delay = luaL_checkint(L,2); int repeats = luaL_checkint(L,3); if (!delay || repeats < 0 || !funcName) { lua_pushnumber(L, LUA_REFNIL); return 1; } lua_remove(L, 1); lua_remove(L, 1);//repeats, args lua_State * thread = lua_newthread(L); //repeats, args, thread lua_insert(L,1); //thread, repeats, args lua_xmove(L,thread,lua_gettop(L)-1); //thread int ref = luaL_ref(L, LUA_REGISTRYINDEX); //empty if(ref == LUA_REFNIL || ref == LUA_NOREF) return luaL_error(L,"Error in RegisterTimedEvent! Failed to create a valid reference."); TimedEvent *te = TimedEvent::Allocate(&g_luaMgr, new CallbackP2<LuaEngineMgr, const char*, int>(&g_luaMgr, &LuaEngineMgr::HyperCallFunction, funcName, ref), EVENT_LUA_TIMED, delay, repeats); EventInfoHolder * ek = new EventInfoHolder; ek->funcName = funcName; ek->te = te; g_luaMgr.m_registeredTimedEvents.insert( make_pair(ref, ek) ); LuaEvent.event_AddEvent(te); lua_settop(L,0); lua_pushnumber(L, ref); return 1; }
void LuaScript::_newState(){ if(innerData().refKeya > 0){ luaL_unref(LuaScriptManager::getInstance()->L, LUA_REGISTRYINDEX, InnerData().refKeya); } innerData().L = lua_newthread(LuaScriptManager::getInstance()->L); innerData().refKeya = luaL_ref(LuaScriptManager::getInstance()->L, LUA_REGISTRYINDEX); }
LuaCoroutine LuaState::NewCoroutine() { lua_State* thread = lua_newthread(m_state); int ref = luaL_ref(m_state, LUA_REGISTRYINDEX); return LuaCoroutine(thread, ref); }
CLuaScript::CLuaScript(IHashString *parentName, IHashString *name) : OBJECTTEMPLATE(CLuaManager, CLuaScript, IObject, parentName, name) { m_EngineToolBox = EngineGetToolBox(); lua_State *temp; static DWORD msgHash_GetMasterScriptState = CHashString(_T("GetMasterScriptState")).GetUniqueID(); if(m_EngineToolBox->SendMessage(msgHash_GetMasterScriptState, sizeof(lua_State *), &temp) != MSG_HANDLED) { StdString error; error = _T("Error missing state data\n"); // log error EngineGetToolBox()->SetErrorValue(WARN_INVALID_OPERATION); EngineGetToolBox()->Log(LOGWARNING, error); assert(0); } // create a thread/state for this object m_pThreadState = lua_newthread(temp); // save a pointer to the thread manager object in the global table // using the new thread's vm pointer as a key lua_pushlightuserdata(temp, m_pThreadState); lua_pushlightuserdata(temp, this ); lua_settable(temp, LUA_GLOBALSINDEX ); AddToHierarchy(); m_bAutoStart = false; m_ScriptBody = NULL; }
static int luaB_newthread (lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); int nTop = lua_gettop(L); lua_State* newthr = lua_newthread(L); int ref = luaL_ref(L, LUA_REGISTRYINDEX);//放到C注册表中防止被回收 lua_xmove(L, newthr, nTop);//把启动函数以及参数移到新的lua_State 中 SysThread *st = (SysThread *)lua_newuserdata(L, sizeof(SysThread)); st->ref = ref; st->thread = newthr; //创建系统线程 if ((st->handle = CreateThread(NULL, NULL, ThreadProc, st, CREATE_SUSPENDED, &st->id))) { luaL_newmetatable(L, TNAMESTR_SYSTHREAD); //创建一个类型为 TNAMESTR_SYSTHREAD 的userdata luaL_newlib(L, systhreadlib); lua_setfield(L, -2, "__index"); lua_setmetatable(L, -2); } else //创建失败,返回false if (!st->handle) { lua_pushboolean(L, 0); } return 1; }
static int syck_load(lua_State *L) { struct parser_xtra *bonus; SyckParser *parser; SYMID v; int obj; if (!luaL_checkstring(L, 1)) luaL_typerror(L, 1, "string"); parser = syck_new_parser(); parser->bonus = S_ALLOC_N(struct parser_xtra, 1); bonus = (struct parser_xtra *)parser->bonus; bonus->orig = L; bonus->L = lua_newthread(L); syck_parser_str(parser, (char *)lua_tostring(L, 1), lua_strlen(L, 1), NULL); syck_parser_handler(parser, lua_syck_parser_handler); syck_parser_error_handler(parser, lua_syck_error_handler); v = syck_parse(parser); syck_lookup_sym(parser, v, (char **)&obj); syck_free_parser(parser); lua_pop(L,1); //pop the thread, we don't need it anymore. lua_xmove(bonus->L, L, 1); if ( parser->bonus != NULL ) S_FREE( parser->bonus ); return 1; }
static int call_lua( lua_State *L ) { const int argc = lua_gettop( L ); lpthread_t *th = (lpthread_t*)luaL_checkudata( L, 1, MODULE_MT ); // create coroutine lua_State *co = NULL; // invalid argument if( lua_type( L, 2 ) != LUA_TFUNCTION ){ lua_pushboolean( L, 0 ); lua_pushstring( L, strerror( EINVAL ) ); return 2; } // lock lpth_task_lock( th ); // create coroutine if( ( co = lua_newthread( th->task.L ) ) ){ lua_xmove( L, co, argc - 1 ); pthread_cond_signal( &th->cond ); lpth_task_unlock( th ); lua_pushboolean( L, 1 ); return 1; } // unlock lpth_task_unlock( th ); // mem error lua_pushboolean( L, 0 ); lua_pushstring( L, strerror( errno ) ); return 2; }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AvHTeamNumber AvHLUA::OnVictoryCheck() { // GC TEST //int limit = lua_getgcthreshold(this->mGlobalContext); /* previous limit */ //lua_setgcthreshold(this->mGlobalContext, 0); /* force a GC cicle */ //lua_setgcthreshold(this->mGlobalContext, limit); if (this->mLoaded && this->definedOnVictoryCheck) { lua_State *threadState = lua_newthread(this->mGlobalContext); lua_getglobal(threadState, "OnVictoryCheck"); if (!lua_isfunction(threadState, -1)) { // not found, mark and exit this->definedOnVictoryCheck = false; return TEAM_IND; } if (int errorcode = lua_resume(threadState, 0)) AvHLUA_OnError(lua_tostring(threadState, -1)); else { // Return the team that won if (lua_isnumber(threadState, -1)) return (AvHTeamNumber)((int)lua_tonumber(threadState, -1)); } } return TEAM_IND; }
/* * Returns: [evq_udata] */ static int levq_new (lua_State *L) { struct event_queue *evq = lua_newuserdata(L, sizeof(struct event_queue)); memset(evq, 0, sizeof(struct event_queue)); lua_assert(sizeof(struct event) >= sizeof(struct timeout_queue)); lua_assert(sizeof(struct event) >= sizeof(struct evq_sync_op)); if (!evq_init(evq)) { lua_State *NL; luaL_getmetatable(L, EVQ_TYPENAME); lua_setmetatable(L, -2); lua_newtable(L); /* environ. (EVQ_CORO_ENV) */ lua_pushvalue(L, -1); lua_setfenv(L, -3); NL = lua_newthread(L); if (!NL) return 0; evq->L = NL; lua_rawsetp(L, -2, NL); /* save coroutine to avoid GC */ lua_newtable(L); /* {ev_id => cb_func} (EVQ_CORO_CALLBACK) */ lua_newtable(L); /* {ev_id => obj_udata} (EVQ_CORO_UDATA) */ lua_xmove(L, NL, 3); return 1; } return sys_seterror(L, 0); }
static int newthread(lua_State *parent) { pthread_t thread; p_states st = (p_states) malloc(sizeof(t_states)); if (!st) luaL_error(parent, "out of memory"); st->parent = parent; luaL_checktype(st->parent, 1, LUA_TFUNCTION); luaL_checktype(st->parent, 2, LUA_TTABLE); lua_settop(st->parent, 2); st->child = lua_newthread(st->parent); if (st->child == NULL) luaL_error(st->parent, "cannot create new stack"); /* create a hard reference to the thread object into the registry */ lua_pushlightuserdata(st->parent, st->child); lua_insert(st->parent, -2); lua_settable(st->parent, LUA_REGISTRYINDEX); /* kill extra mutex created by lua_newthread and copy parent's over it */ pthread_mutex_destroy(lt_mutex(st->child)); lt_mutex(st->child) = lt_mutex(st->parent); /* move args table and function to child's stack */ lua_xmove(st->parent, st->child, 1); lua_xmove(st->parent, st->child, 1); /* create a new thread of execution and we are done */ if (pthread_create(&thread, NULL, thread_entry, st) != 0) luaL_error(st->parent, "cannot create new thread"); return 0; }
static int luaB_cocreate (lua_State *L) { lua_State *NL = lua_newthread(L); luaL_checktype(L, 1, LUA_TFUNCTION); lua_pushvalue(L, 1); /* move function to top */ lua_xmove(L, NL, 1); /* move function from L to NL */ return 1; }
bool ModifyScriptDescriptor::OpenFile(const std::string& file_name) { if (ScriptManager->IsFileOpen(file_name) == true) { IF_PRINT_WARNING(SCRIPT_DEBUG) << "SCRIPT WARNING: ModifyScriptDescriptor::OpenFile() attempted to open file that is already opened: " << file_name << std::endl; return false; } // Check if this file was opened previously. if ((this->_lstack = ScriptManager->_CheckForPreviousLuaState(file_name)) == NULL) { // Increases the global stack size by 1 element. That is needed because the new thread will be pushed in the // stack and we have to be sure there is enough space there. lua_checkstack(ScriptManager->GetGlobalState(),1); _lstack = lua_newthread(ScriptManager->GetGlobalState()); // Attempt to load and execute the Lua file. if (luaL_loadfile(_lstack, file_name.c_str()) != 0 || lua_pcall(_lstack, 0, 0, 0)) { PRINT_ERROR << "SCRIPT ERROR: ModifyScriptDescriptor::OpenFile() could not open the file " << file_name << std::endl; _access_mode = SCRIPT_CLOSED; return false; } } // Write out some global stuff _filename = file_name; _access_mode = SCRIPT_MODIFY; ScriptManager->_AddOpenFile(this); return true; } // bool ModifyScriptDescriptor::OpenFile(std::string file_name)
static inline int box_process_lua(struct request *request, struct obuf *out, lua_CFunction handler) { struct lua_function_ctx ctx = { request, out, {0, 0, 0}, false }; lua_State *L = lua_newthread(tarantool_L); int coro_ref = luaL_ref(tarantool_L, LUA_REGISTRYINDEX); int rc = lbox_cpcall(L, handler, &ctx); luaL_unref(tarantool_L, LUA_REGISTRYINDEX, coro_ref); if (rc != 0) { if (ctx.out_is_dirty) { /* * Output buffer has been altered, rollback to svp. * (!) Please note that a save point for output buffer * must be taken only after finishing executing of Lua * function because Lua can yield and leave the * buffer in inconsistent state (a parallel request * from the same connection will break the protocol). */ obuf_rollback_to_svp(out, &ctx.svp); } return -1; } return 0; }
void xd::lua::scheduler::start(luabind::object func) { // create a new thread lua_State *thread = lua_newthread(m_vm.lua_state()); // push the function in the new thread, because the function // the thread calls must be called in its local environment func.push(thread); // construct a callable object from it, the value is copied from stack luabind::object thread_func(luabind::from_stack(thread, -1)); // remove the original value from the stack lua_pop(thread, 1); // set the current thread m_thread_stack->threads.push(thread); m_current_thread = thread; // start the thread luabind::object result = luabind::resume_function<luabind::object>(thread_func); // if the thread was yielded from lua side, and the return value is a callable function int type = luabind::type(result); if (type == LUA_TFUNCTION || type == LUA_TTABLE || type == LUA_TUSERDATA) { yield(xd::create<detail::callback_task_lua>(result)); } // reset current thread m_thread_stack->threads.pop(); if (m_thread_stack->threads.empty()) m_current_thread = nullptr; else m_current_thread = m_thread_stack->threads.top(); }
static int newthread(lua_State *parent) { lua_State *child = NULL; pthread_t thread; luaL_checktype(parent, 1, LUA_TFUNCTION); luaL_checktype(parent, 2, LUA_TTABLE); lua_settop(parent, 2); child = lua_newthread(parent); if (child == NULL) luaL_error(parent, "cannot create new stack"); /* create a hard reference to the thread object into the registry */ lua_pushlightuserdata(parent, child); lua_insert(parent, -2); lua_settable(parent, LUA_REGISTRYINDEX); /* move args table and function to child's stack */ lua_xmove(parent, child, 1); lua_xmove(parent, child, 1); /* increase the count of active threads */ lt_activeup(parent); /* create a new thread of execution and we are done */ if (pthread_create(&thread, NULL, thread_entry, child) != 0) { /* undo lt_activeup because we failed */ lt_activedown(parent); /* report our failure */ luaL_error(parent, "cannot create new thread"); } return 0; }
bool ReadScriptDescriptor::OpenFile(const std::string& filename, bool force_reload) { // check for file existence if (!DoesFileExist(filename)) { PRINT_ERROR << "Attempted to open unavailable file: " << filename << std::endl; return false; } if (ScriptManager->IsFileOpen(filename)) { PRINT_ERROR << "Attempted to open file that is already opened: " << filename << std::endl; return false; } // Check if this file was opened previously. if ((force_reload) || (_lstack = ScriptManager->_CheckForPreviousLuaState(filename)) == NULL) { // Increases the global stack size by 1 element. That is needed because the new thread will be pushed in the // stack and we have to be sure there is enough space there. lua_checkstack(ScriptManager->GetGlobalState(), 1); _lstack = lua_newthread(ScriptManager->GetGlobalState()); // Attempt to load and execute the Lua file if (luaL_loadfile(_lstack, filename.c_str()) != 0 || lua_pcall(_lstack, 0, 0, 0)) { PRINT_ERROR << "could not open script file: " << filename << ", error message:" << std::endl << lua_tostring(_lstack, private_script::STACK_TOP) << std::endl; _access_mode = SCRIPT_CLOSED; return false; } } _filename = filename; _access_mode = SCRIPT_READ; ScriptManager->_AddOpenFile(this); return true; } // bool ReadScriptDescriptor::OpenFile(string file_name, bool force_reload)
LuaCoroutine Lua::CreateCoroutine() { lua_newthread(state.get()); LuaCoroutine thread(state, -1); lua_pop(state.get(), 1); return thread; }
static int syck_dump(lua_State *L) { SyckEmitter *emitter; struct emitter_xtra *bonus; emitter = syck_new_emitter(); emitter->bonus = S_ALLOC_N(struct emitter_xtra, 1); bonus = (struct emitter_xtra *)emitter->bonus; bonus->L = lua_newthread(L); luaL_buffinit(L, &bonus->output); syck_emitter_handler(emitter, lua_syck_emitter_handler); syck_output_handler(emitter, lua_syck_output_handler); lua_pushvalue(L, -2); lua_xmove(L, bonus->L, 1); bonus->id = 1; lua_syck_mark_emitter(emitter, bonus->id); bonus->id = 1; syck_emit(emitter, (st_data_t)((long)bonus->id)); syck_emitter_flush(emitter, 0); luaL_pushresult(&bonus->output); syck_free_emitter(emitter); return 1; }
static void* server_thread_main(void* ctx) { orka_server_t* server = ctx; pthread_detach(server->thread); while(1) { struct sockaddr client_addr; socklen_t client_addr_len = sizeof(client_addr); int client_fd = accept(server->fd, &client_addr, &client_addr_len); if(client_fd < 0) { if(errno == EINTR) { continue; } orka_error(server->lua, "accept"); } #ifdef SO_NOSIGPIPE int one = 1; setsockopt(client_fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(one)); #endif orka_client_t* client = malloc(sizeof(*client)); orka_gil_acquire(); client->lua = lua_newthread(server->lua); lua_rawgeti(server->lua, LUA_REGISTRYINDEX, server->handler_ref); lua_xmove(server->lua, client->lua, 1); orka_gil_release(); client->fd = client_fd; pthread_create(&client->thread, NULL, client_thread_main, client); } return NULL; }
static int syck_load(lua_State *L) { struct parser_xtra *bonus; SyckParser *parser; SYMID v; int obj; if (!luaL_checkstring(L, 1)) luaL_typerror(L, 1, "string"); parser = syck_new_parser(); parser->bonus = S_ALLOC_N(struct emitter_xtra, 1); bonus = (struct parser_xtra *)parser->bonus; bonus->L = lua_newthread(L); syck_parser_str(parser, (char *)lua_tostring(L, 1), lua_strlen(L, 1), NULL); syck_parser_handler(parser, lua_syck_parser_handler); v = syck_parse(parser); syck_lookup_sym(parser, v, (void *)&obj); syck_free_parser(parser); lua_xmove(bonus->L, L, 1); return 1; }
lua_State * ngx_http_lua_new_thread(ngx_http_request_t *r, lua_State *L, int *ref) { int top = lua_gettop(L); lua_getfield(L, LUA_REGISTRYINDEX, NGX_LUA_CORT_REF); lua_State *cr = lua_newthread(L); if(cr) { /* new globals table for coroutine */ lua_newtable(cr); /* {{{ inherit coroutine's globals to main thread's globals table */ /* for print() function will try to find tostring() in current globals */ /* table. */ lua_newtable(cr); lua_pushvalue(cr, LUA_GLOBALSINDEX); lua_setfield(cr, -2, "__index"); lua_setmetatable(cr, -2); /* }}} */ lua_replace(cr, LUA_GLOBALSINDEX); *ref = luaL_ref(L, -2); if(*ref == LUA_NOREF) { lua_settop(L, top); /* restore main trhead stack */ return NULL; } } /* pop coroutine refernece on main thread's stack after anchoring it in registery */ lua_pop(L, 1); return cr; }
int main (int argc, char **argv) { int status; struct Smain s; lua_State *L = lua_open(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } while (1) { lua_State* l = lua_newthread(L); lua_pop(L, 1); //lua_pop(l, 1); //TodLuaScriptServer::instance()->newThread(STRING("managed://script#damage_mob.lua")); } s.argc = argc; s.argv = argv; status = lua_cpcall(L, &pmain, &s); report(L, status); lua_close(L); return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; }
int Pemitter (lua_State *L) { lyaml_emitter *emitter; lua_newtable (L); /* object table */ /* Create a user datum to store the emitter. */ emitter = (lyaml_emitter *) lua_newuserdata (L, sizeof (*emitter)); emitter->error = 0; /* Initialize the emitter. */ if (!yaml_emitter_initialize (&emitter->emitter)) { if (!emitter->emitter.problem) emitter->emitter.problem = "cannot initialize emitter"; return luaL_error (L, "%s", emitter->emitter.problem); } yaml_emitter_set_unicode (&emitter->emitter, 1); yaml_emitter_set_width (&emitter->emitter, 2); yaml_emitter_set_output (&emitter->emitter, &append_output, emitter); /* Set it's metatable, and ensure it is garbage collected properly. */ luaL_newmetatable (L, "lyaml.emitter"); lua_pushcfunction (L, emitter_gc); lua_setfield (L, -2, "__gc"); lua_setmetatable (L, -2); /* Set the emit method of object as a closure over the user datum, and return the whole object. */ lua_pushcclosure (L, emit, 1); lua_setfield (L, -2, "emit"); /* Set up a separate thread to collect error messages; save the thread in the returned table so that it's not garbage collected when the function call stack for Pemitter is cleaned up. */ emitter->errL = lua_newthread (L); luaL_buffinit (emitter->errL, &emitter->errbuff); lua_setfield (L, -2, "errthread"); /* Create a thread for the YAML buffer. */ emitter->outputL = lua_newthread (L); luaL_buffinit (emitter->outputL, &emitter->yamlbuff); lua_setfield (L, -2, "outputthread"); return 1; }
void canXmove_ValidParentChildBothWithAStackCountOfOne_bothHaveStackCountIsOneAfterCall() { lua_State * child = lua_newthread(*m_lua);//thread on m_lua stack lua_pushnil(child); OOLUA::can_xmove(*m_lua, child); CPPUNIT_ASSERT(lua_gettop(*m_lua) == 1 && lua_gettop(child) == 1); }
static int luaB_cocreate (lua_State *L) { lua_State *NL = lua_newthread(L); luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); lua_pushvalue(L, 1); /* move function to top */ lua_xmove(L, NL, 1); /* move function from L to NL */ return 1; }
void dt_lua_delay_chunk(lua_State *L,int nargs) { lua_getfield(darktable.lua_state,LUA_REGISTRYINDEX,"dt_lua_delayed_events"); lua_State * new_thread = lua_newthread(L); int my_id = luaL_ref(L,-2); lua_pop(L,1); lua_xmove(L,new_thread,nargs+1); gdk_threads_add_idle(poll_events,GINT_TO_POINTER(my_id)); }
int main() { // Lua 를 초기화 한다. lua_State* L = lua_open(); // Lua 기본 함수들을 로드한다.- print() 사용 luaopen_base(L); // Lua 문자열 함수들을 로드한다.- string 사용 luaopen_string(L); // TestFunc 함수를 Lua 에 등록한다. lua_tinker::def(L, "TestFunc", &TestFunc); lua_tinker::def(L, "TestFunc2", &TestFunc2); // TestClass 클래스를 Lua 에 추가한다. lua_tinker::class_add<TestClass>(L, "TestClass"); // TestClass 의 함수를 등록한다. lua_tinker::class_def<TestClass>(L, "TestFunc", &TestClass::TestFunc); lua_tinker::class_def<TestClass>(L, "TestFunc2", &TestClass::TestFunc2); // TestClass 를 전역 변수로 선언한다. TestClass g_test; lua_tinker::set(L, "g_test", &g_test); // sample3.lua 파일을 로드한다. lua_tinker::dofile(L, "sample6.lua"); // Thread 를 시작한다. lua_newthread(L); lua_pushstring(L, "ThreadTest"); lua_gettable(L, LUA_GLOBALSINDEX); // Thread 를 시작한다. printf("* lua_resume() 호출\n"); lua_resume(L, 0); // Thread 를 다시 시작한다. printf("* lua_resume() 호출\n"); lua_resume(L, 0); // Thread 를 다시 시작한다. printf("* lua_resume() 호출\n"); lua_resume(L, 0); // Thread 를 다시 시작한다. printf("* lua_resume() 호출\n"); lua_resume(L, 0); // Thread 를 다시 시작한다. printf("* lua_resume() 호출\n"); lua_resume(L, 0); // 프로그램 종료 lua_close(L); return 0; }
QuestState CQuestManager::OpenState(const string& quest_name, int state_index) { QuestState qs; qs.args=0; qs.st = state_index; qs.co = lua_newthread(L); qs.ico = lua_ref(L, 1/*qs.co*/); return qs; }
ObjectScriptExecutor::ObjectScriptExecutor(ObjectScript* script, Object* object) { this->script = script; this->object = object; threadState = lua_newthread(objectScriptManager.masterState); objectScriptManager.addToStateMap(this); stop(); }
static gboolean alien_job_dispatch (GSource* source, GSourceFunc callback, gpointer user_data) { gpointer message; message = g_async_queue_try_pop (darktable.lua_state.alien_job_queue); if (message == NULL) { return TRUE; } async_call_data* data = (async_call_data*)message; dt_lua_lock(); lua_State* L= darktable.lua_state.state; lua_State *new_thread = lua_newthread(L); int reference = save_thread(L); lua_pushlightuserdata(new_thread,data->cb); lua_pushlightuserdata(new_thread,data->cb_data); lua_pushinteger(new_thread,data->nresults); lua_pushcfunction(new_thread,data->pusher); GList* cur_elt = data->extra; while(cur_elt) { GList * type_type_elt = cur_elt; cur_elt = g_list_next(cur_elt); GList * type_elt = cur_elt; cur_elt = g_list_next(cur_elt); GList * data_elt = cur_elt; cur_elt = g_list_next(cur_elt); switch(GPOINTER_TO_INT(type_type_elt->data)) { case LUA_ASYNC_TYPEID_WITH_FREE: // skip the destructor cur_elt = g_list_next(cur_elt); // do not break case LUA_ASYNC_TYPEID: luaA_push_type(new_thread,GPOINTER_TO_INT(type_elt->data),data_elt->data); break; case LUA_ASYNC_TYPENAME_WITH_FREE: // skip the destructor cur_elt = g_list_next(cur_elt); // do not break case LUA_ASYNC_TYPENAME: luaA_push_type(new_thread,luaA_type_find(L,type_elt->data),&data_elt->data); break; case LUA_ASYNC_DONE: default: // should never happen g_assert(false); break; } } run_async_thread(L,reference); dt_lua_unlock(); alien_job_destroy(data); return G_SOURCE_CONTINUE; }