[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: multiple embedded interpreters?
- From: "Kevin Baca" <lualist@...>
- Date: Tue, 4 Jan 2005 16:03:48 -0800
> Is there any reason that I shouldn't just launch a new embedded lua
> interpreter for each "team" that uses a lua-based AI, to avoid
> all the possible scoping issues and such? The total number of
> concurrent lua interpreters is likely to be a handful at most, which
> doesn't seem like it would require too much memory, etc. It looks
> more attractive than the alternative of enforcing scope on multiple
> chunks handled by the same interpreter.
Some reasons for not using mutiple Lua states are the added memory,
complexity, and CPU costs.
Each state has its own memory pool and performs its GC separately from
Enforcing scope is not really as much of a pain as it might seem.
You can rather easily set up multiple lua environments, each with its
own set of globals, all coexisting in the same Lua state.
Have a look at loadfile() and the environment handling functions
getfenv() and setfenv().
Also do a search for "sandbox" in the archives.