Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I immediately thought of Lua as well. A fine choice, Lua has the best C FFI I've ever worked with. I love everything about this.


Does Lua work well with multiple threads?


Lua has full support for creating multiple interpreter instances (ie. there are no global variables, and it's totally re-entrant). But interpreter instances are not thread-safe. So the way to support multiple threads is to have completely independent interpreters running in different threads.


You can make a Lua interpreter thread safe by adding a GIL. There is implicit support for this in the code: the interpreter invokes lua_lock/lua_unlock at the proper places, the default Lua implementation just has them NOP'd out. Adding the thread primitives is up to you, however.


when you have multiple threads, isn't the idea to share data between threads? I haven't really worked with embedded lua before - does lua help with that?


Thanks. Any idea as to the footprint of these instances?


I use this approach in Fire★ (http://www.firestr.com). Lua vm instances are tiny. There is a reason lua is used even in systems like nintendo DS




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: