Skip to main content

xmove

Function xmove 

Source
pub fn xmove(from: &mut LuaState, to: &mut LuaState, n: i32)
Expand description

Move the top n values from from’s stack onto to’s stack.

Both threads must share the same GlobalState (i.e. one is a coroutine the other created via coroutine.create). Calling with from == to is a no-op. Equivalent to:

args = from.stack[top-n..top].clone();
from.set_top(top - n);
for v in args { to.push(v); }

C: LUA_API void lua_xmove (lua_State *from, lua_State *to, int n)

Phase E-3: implemented for the same-GlobalState case (the only one lua-stdlib uses today). lua-vm callers should prefer this helper over hand-rolling the snapshot/push dance.