lua-users home
lua-l archive

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


> Have anyone worked with Lua 3.1 in a win32 multithreaded enviroment. I was trying
> to have a lua_state for each thread (By using the __declspec(thread) on
> lua_state) but it seems to crash on me. Without anything I can get Lua to run
> great in two thread but with a common Global scope - I want the global variables
> to be thread specific (Actually trigger-code section specific). I'm compiling
> with Watcom 11 - have not have time to try with VC++ 5.0 yet.
> 

I've actually have this working great.  All I needed to do was declare
the lua_state variable a thread local variable, and as long as each thread
only accesses its own instance things are fine.  I did this with VC++ 
not Watcom.  We have gotten multiple Lua instances to run in separate
threads for at least two or three of them running simulatenously.  Perhaps
you should make sure your ANSI calls malloc() and free() are thread safe,
as well as any stdio.h library calls you use.

BTW, has any work been done on getting Lua to use a pool-type allocator
rather than malloc/free?  This would help for limited memory situations
and running on embedded systems.

Dan

Dan Marks
dmarks@uiuc.edu