lua-users home
lua-l archive

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


Hi, I am a pretty new to Lua still, so please forgive me :)

I am wanting to use lua in a multithreaded application, and I can find lots of information about how to do threaded / psuedo threaded things in Lua, but this is not what I am looking for. My understanding is, that the interpreter/jit is single threaded, and I want to know how to ensure that I am not blocking my multithreaded app by executing all my scripts in a single thread.

If it helps, my goal is to use LuaJIT with ZeroMQ, and have zmq manage the parallel workflow of a bunch of services written in Lua. I have looked at the wrapper lua-zmq, and I assume this is using lua in a truly multithreaded way, but I don't know how to confirm. What is the trick, what do I look for? Do we have to start an interpreter in every thread, or is it enough just to create a new state?

When I look at the C code where people are embedding Lua in their programs, I don't ever really see something that looks like "the interpreter starts running here", just setting up a new Lua state.

Is using the LuaJIT to wrap zmq the same as embedding LuaJIT in a program which links against ZMQ?

I am happy to read more, I don't need anyone to write a book here, but when I google "mutlithreaded Lua" I get a bunch of answers to a different question (namely, "how to i make my lua script multithreaded?") which doesn't interest me at all. I actually want to write single threaded Lua code which will execute in the multithreaded message passing way which ZeroMQ manages so well.

Thanks,
Nick