lua-users home
lua-l archive

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


2006/11/8, Simon Wittber <simonwittber@gmail.com>:
I got the impression lua could work with real threads from here:
http://www.cs.princeton.edu/~diego/professional/luathread/examples.html
Are these examples out of date or deprecated?

IIRC LuaThread patch you link allows multiple threads to access a
single lua state in a safe manner, but it uses a single lock per Lua
state (that is a full instance of lua engine), so you cannot execute
multiples scripts on multiple processors at the same time.

The best solution imho with current Lua is to use at least one lua
state per physical thread, with some custom mechanism to share
information and events. But you will find plenty of mails discussing
that topic in the list archive.

2006/11/7, Thomas Harning Jr. <harningt@gmail.com>:
> Is there a facility which lets Lua programs dynamically load arbitrary
> shared C modules?
There was one somewhere for loading arbitrary libraries/functions, but
I can't remember.  This method is probably something to avoid in a
game engine due to speed requirements... it'd  probably be better to
create a wrapper library for Lua to load in to access external library
functionality.

The function to load a dynamic library is 'package.loadlib'. The
'require' function can also do that if the library is built around the
Lua package model.

And I'd like to add that contrary to what Thomas wrote, loading a
dynamic/shared library the way Lua does it, that is by calling
LoadLibrary/dlopen and then getting a pointer to the functions in the
DLL, is faster than using a stub library and statically linking to
that stub library. The stub static library adds a level of indirection
compared to the use of functions pointer retrieved directly from the
manually loaded dll.