lua-users home
lua-l archive

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


I’m working on an application that’s multi-threaded, and to avoid a newstate-load-pcall-close series for every time I want to invoke a script, I’m thinking of allocating a pool of states and just pulling one out when it’s time to run, which leaves me with just load-pcall every time.

 

One thing I’m not certain about with that design: Will the garbage collector purge any global variables that exist in the state on completion of the pcall, or will they linger around for the next load-pcall on the same state object?  If the latter, can I use some getfenv/setfenv magic to reset things for the next iteration?  Or do I have to bite the bullet and do it the more expensive way?

Thanks,

-MSK