Skip to main content

luaur_vm/functions/
lua_newthread.rs

1use crate::functions::lua_concat::lua_c_threadbarrier_lapi;
2use crate::functions::lua_e_newthread::lua_e_newthread;
3use crate::macros::api_incr_top::api_incr_top;
4use crate::macros::lua_c_check_gc::luaC_checkGC;
5use crate::macros::setthvalue::setthvalue;
6use crate::records::global_state::global_State;
7use crate::type_aliases::lua_state::lua_State;
8
9pub unsafe fn lua_newthread(L: *mut lua_State) -> *mut lua_State {
10    luaC_checkGC!(L);
11    lua_c_threadbarrier_lapi(L);
12    let L1 = lua_e_newthread(L);
13    setthvalue!(L, (*L).top, L1);
14    api_incr_top!(L);
15    let g = (*L).global as *mut global_State;
16    if let Some(userthread) = (*g).cb.userthread {
17        userthread(L, L1);
18    }
19    L1
20}