MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lua_newthread

Function lua_newthread

libraries/AP_Scripting/lua/src/lstate.c:263–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261
262
263LUA_API lua_State *lua_newthread (lua_State *L) {
264 global_State *g = G(L);
265 lua_State *L1;
266 lua_lock(L);
267 luaC_checkGC(L);
268 /* create new thread */
269 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
270 L1->marked = luaC_white(g);
271 L1->tt = LUA_TTHREAD;
272 /* link it on list 'allgc' */
273 L1->next = g->allgc;
274 g->allgc = obj2gco(L1);
275 /* anchor it on L stack */
276 setthvalue(L, L->top, L1);
277 api_incr_top(L);
278 preinit_thread(L1, g);
279 L1->hookmask = L->hookmask;
280 L1->basehookcount = L->basehookcount;
281 L1->hook = L->hook;
282 resethookcount(L1);
283 /* initialize L1 extra space */
284 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
285 LUA_EXTRASPACE);
286 luai_userstatethread(L, L1);
287 stack_init(L1, L); /* init stack */
288 lua_unlock(L);
289 return L1;
290}
291
292
293void luaE_freethread (lua_State *L, lua_State *L1) {

Callers 1

luaB_cocreateFunction · 0.85

Calls 3

preinit_threadFunction · 0.85
memcpyFunction · 0.85
stack_initFunction · 0.85

Tested by

no test coverage detected