News for hackers. Stuff that matters.
Re:Duktape: an embeddable JavaScript engine by haberman on Thursday December 04, 2014 @04:06PM (#8701634)
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.
Re:Duktape: an embeddable JavaScript engine by sharkbot on Thursday December 04, 2014 @06:54PM (#8702421)
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.
Re:Duktape: an embeddable JavaScript engine by chii on Thursday December 04, 2014 @11:00PM (#8702958)
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?
Re:Duktape: an embeddable JavaScript engine by cheez on Thursday December 04, 2014 @04:52PM (#8701905)
Thanks. Any idea as to the footprint of these instances?
Re:Duktape: an embeddable JavaScript engine by mempko on Thursday December 04, 2014 @05:27PM (#8702101)
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