lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If you have one lua_State * L1, and create another L2 using lua_newthread(L1), then they are 'different threads of the same state'. All coroutines spawned in a state are also 'new threads' of that same state. Using lua_xmove in between any of these is safe. lua_newthread() is basically how you create a new coroutine from C. 


On Mar 15, 2012, at 6:34 AM, Rodrigo Dias Arruda Senra wrote:

> Em 13/03/2012 14:59, Graham Wakefield escreveu:
>> On Mar 13, 2012, at 2:52 AM, Peter Pimley wrote:
>> 
>>> Is there an easy way to move the function from one lua_State's stack to another's?
>> lua_xmove()
>> 
> 
> Curiously the docs says:
> 
>  http://www.lua.org/manual/5.2/manual.html#lua_xmove <http://www.lua.org/manual/5.2/manual.html#lua_xmove>
> 
>  Exchange values between different threads of the same state.
> 
>  This function pops|n|values from the stack|from|, and pushes them onto the stack|to|.
> 
> 
> Therefore, it seems that lua_xmove does *not* move across different lua_State.
> 
> 
> -- 
> 
> Atenciosamente
> 
> _Rodrigo Dias Arruda Senra_
> *Engenheiro de Computação*
> 
> *HI Tecnologia - Indústria e Comércio Ltda
> *Campinas - SP
> Fone: +55 (19) 2139-1700
> Fax: +55 (19) 2139-1710
> /Email: rodrigo.senra@hitecnologia.com.br <mailto:rodrigo.senra@hitecnologia.com.br>
> Web-site: / /www.hitecnologia.com.br/
> <http://www.hitecnologia.com.br>/*P*Antes de imprimir, pense em sua responsabilidade e compromisso com o *Meio Ambiente.*/
> 
> //