Re: Lua in multithread systems
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua in multithread systems
- From: Asko Kauppi <askok@...>
- Date: 2007年10月29日 16:46:21 +0200
The Kepler people might be best to answer your needs, or even show
you ready components to utilize.
http://www.keplerproject.org/
1. You might be overestimating the time taken to initialize/close up
Lua states. I would just make a brand new state, each time, and
close it properly.
2. One solution would be to make a C module that does the data
interchanging, and locking.
My throw into the Lua multithreaded arena is Lua Lanes, which does
offer queues etc. but it's not directly intended for server side
functionality. However, there is a comparison section which might be
helpful:
http://kotisivu.dnainternet.net/askok/bin/lanes/index.html
-asko
Daniel van Ham Colchete kirjoitti 29.10.2007 kello 15:21:
Hello yall,
I'm developing a multithread system, a server answering to a lot of
connections at the same time. I'm using Lua to easier the job of
having custom made versions. Everything is in C++ and I'm using
Luna.h.
Now I'm at the point of choosing how I will use multi thread with
Lua. For now I implemented a lua pool (no queues yet) that gives me
an already initialized lua_State* whenever I need one. So, I open a
new thread (using PThreads on Linux), get an unused lua_State* from
the pool, send the inputs, run the script and get the results back.
But this model has 2 problems to me:
1 - Scope pollution: and second time I run the script with the same
lua_State* from the pool, the global variables set by the first run
are still there. Is there a fast way to clean only the variables
set by the Lua script?
2 - Global variables are not global anymore. One script doesn't
have access to the global variables set by another instances. On
thread doesn't talk to the other using lua entities: numbers,
tables, etc...
I only need a solution to one of the items, the second preferentially.
But, maybe this model is not good at all. What are you using to
solve the multi thread problem?
Thank you all in advice!
Best regards,
Daniel Colchete