lua-users home
lua-l archive

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


On 29/11/12 20:57, Philipp Kraus wrote:
[...]
> So I think 10^12 LUA parser etc is not recommand, so I would read the LUA script first, parse it (with syntax checking) and create the stack call (lua_call).

I don't believe there's a way to duplicate a Lua state inside a single
process. So you can't create a state, read the script, and then spawn
multiple states to use in different threads.

However, you could create a state, read the script, and then *fork* ---
by duplicating the entire process you also duplicate the Lua state in
the master process.

I assume you're not running all 10^12 simulation steps concurrently,
though, right? Won't you have a thread pool with a thread per core and
then assign work to each thread as the thread is freed up?

If so, you'd be best off creating a Lua state per thread, having the
state read a script, and then each time you assign work to the thread
reuse the existing state.

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "Of course, on a sufficiently small planet, 40 km/hr is, in fact,
│ sufficient to punt the elastic spherical cow into low orbit." ---
│ Brooks Moses on r.a.sf.c

Attachment: signature.asc
Description: OpenPGP digital signature