lua-users home
lua-l archive

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


thanks for yours quickly response.

I use tool tolua++ bind a C++ class to lua, and found that it expose a instance of class to lua, so confused whether it is reentrantable for lua script.

in my scenario, I will create many instance of the class in lua script, tolua++ can support that? and how to write a entrantable library? it is my question.

thanks.
 
------------------ Original ------------------
Date:  Thu, Nov 13, 2008 07:14 PM
To:  "lua"<lua@bazar2.conectiva.com.br>;
Subject:  Re: How to implement a reentrantable library?
 
I did not have any problems using lua from multiple threads
on a multi-cpu machine running windows .
The interface was implemented using the excellent
luabind library.

You must make sure that a single luastate (and therefore
all the calls that use luastate) is not used by multiple threads
at the same time, in my instance, each thread on startup was setup
to have a luastate.  So the same luastate would be used by only that
thread.

So 5 threads, 5 luastates that are permanently attached to each thread.

VSP


On Thu, 13 Nov 2008 07:28:03 -0200, "Luiz Henrique de Figueiredo"
<lhf@tecgraf.puc-rio.br> said:
> >  I want to implement a reentrantable library for Lua, and use it in the same Lua virtual machine with multiple instances. but I don't know how to do it, does anybody has same experience with it,  maybe you can give me some useful tips.
>
> All C libraries for Lua should be reentrant. That means that they should
> not
> rely on any global or static data. See the code for the standard Lua
> libraries
> and also for instance my own libraries at
>     http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/
--
  V S P
  toreason@fastmail.fm

--
http://www.fastmail.fm - Send your email first class