lua-users home
lua-l archive

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


On Fri, Mar 23, 2012 at 8:56 AM, Rodrigo Dias Arruda Senra
<rodrigo.senra@hitecnologia.com.br> wrote:
> 1) Is it worth to pre-allocate a lua_State pool instead of creating it every
> time ?

yes

> 2) If so, in between executions is it enough to clean it using settop(L,0)
> and
>   replacing its _ENV for a empty table ?

not so empty, there's where you register all accessible libraries and functions


> 3) Instead of wrapping <user code> in the template function, could I just
> push it
>   as a Lua chunk and pcall()-it ?

usually yes, but it might be harder to get parameters.  sometimes i
add a callback to fetch values, so i don't need any parameter.


> 4) I have a common set of wrapped C-callbacks that are registered in every
> Lua state.
>   Could I prepare a prototypical Lua State and clone it in the new Lua state
> created
>   with some performance gain instead of registering its contents ?

unfortunately there's no way to clone a State.


in short: if you can get an easy way to cleanup global state, then a
pool of Lua States is usually better.



-- 
Javier