On 8/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
> I'd like to use wxLua in a multi-threading application, several threads
> should host their own Lua instance.
> The Lua instances should run independent from the others, not sharing
> anything.
> So I create a wxLuaState object for every thread and use RunFile to execute
> the script.
No problems, except that any GUI functions MUST be made from the main
thread. This is a limitation of wxWidgets due to the underlying gui
system which is true for pure C++ code as well..
> But: I also want to use own functions (published through RegisterFunction)
> and I can't manage to get them independent.
> I would have to declare them in a global scope (or as static member
> functions), both would lead to a common function
> implementation which is called from all threads. But I want to have them
> separate, to avoid any interference between the Lua threads.
>
> Can anybody give me a hint how to do this?
I think you're wondering how to have the underlying C function
independent for each thread since each
wxLuaState::RegisterFunction(...) call for a given lua state pushes
the function independently into the lua_State already.
Simple case: Just have multiple C functions if you'll only have a
small known number of them.
More complicated: I am not very well versed in C threading, but I
believe that you will have to have mutexes (and/or conditions?) for
each wxLuaState you create (maybe a wxList mapping between the
lua_State of the wxLuaState and it's mutexes, keyed on the memory
location of the lua_State?), then look up from within the C function
which lua_State is "active" and do the mutex thing in there. In other
words lua doesn't know about the threading and the C functions handle
it all internally.
I hope this makes some sort of sense,
John Labenski
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users