lua-users home
lua-l archive

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


I know in PiL it talks about using different threads with entirely different Lua states, and of course it's possible to use entirely separate Lua states in the same thread (I occasionally do this for some unrelated bookkeeping materials in native code).

But what are the best ways (or is it possible at all) to share Lua state among two threads? This doesn't have to be concurrent. I mean, say I want to load a bunch of data and process it in one thread (because it might take a long time) and when that's done, notify another thread running Lua (which is doing some UI stuff, which is why I didn't want to load the data there). How can I transfer the data (say, nested tables) from the first Lua state to the second?

Any pointers to patterns and discussion of this nature would be appreciated.