lua-users home
lua-l archive

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

As Javier wrote, using coroutines (in other words, co-operative multithreading within the Lua state itself) seems like the first way to go.

If you however have a reason to keep the states separate, Lua Lanes and other multithreading libraries are worth looking to. With Lanes, one can call functions in parallel, and once reading their return values, the threads will join but all that happens behind the scene. One can also make a certain lane (= thread = Lua state) a message handler, which other lanes send messages to. Synchronous handling ("calling functions from another state") sounds like a bad idea; it's not really parallel thinking to me.


Tom Miles kirjoitti 15.11.2007 kello 18:54:

I apologise if this is either a stupid question, or has been asked
before, but I was wondering if there was a way that I haven't found of
calling functions of one state from within a lua script of another?  I
have several states all started with lua_newthread() all of which run
their own scripts.  I have a very convoluted method at the moment for
each thread to "talk to each other" which is hideously slow and has been a nightmare to maintain as new situations arise, and was wondering what
the "industry standard" way of doing it was (if there was one)?



---------------------------------------------------------------------- ------
This email is sent by The Creative Assembly Limited company No. 03425917, registered in England &Wales registered office 27 Great West Road, Middlesex, TW8 9BW, England. The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged. Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else. If you have received this email in error, please notify us immediately by e- mail on and then delete the email and any copies. The Creative Assembly Limited have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.