On Wed, Mar 10, 2010 at 8:37 PM, Dewey Gaedcke <de...@minggl.com> wrote:
> So where I'm still lost is that I don't understand how Copas, Xavante, 
> FastCGI or any other technology is able to read (in parallel) a Lua table 
> that exists in my dedicated persistent Lua memory process.

although Copas looks like a multitasking scheduler; it's in fact just
a wrapper around select() that picks the right coroutine to execute.
So, all the Copas 'threads' are coroutines on the same Lua space.
There's no parallel access.

You have several different alternatives to your problem:

- Use Copas or something similar.  here it's all on one Lua space, so
there's no problem accessing the data from any 'thread'.  it's easy to
write TCP servers that access the common resource.

- Use any of different Lua multithreading systems.  Like LuaLanes, or
luaproc (and many more).  These handle several separate Lua spaces
running on parallel;with several different interprocess communication
facilities.  this wouldn't let you directly access the data from any
other thread; but it's easy to write a 'fetch' function that sends
some parameters to a 'server' which does the query and returns the
requested data.  IOW, the thread that holds the data works like a kind
of database server for the other threads.  usually the client fetch
functions could be very short, less than 5 lines each

- put the data on some external resource.  like a database (SQLite
could be perfect, MySQL if you do a lot of reads and few writes, Tokyo
Tyrant if it's best described as a key/value store, memcached,
CouchDB, MongoDB, redis, etc.)


-- 
Javier

_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to