lua-users home
lua-l archive

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



I'd just create two Lua states and use them from separate OS threads.

Assuming that:
- io.write() is thread safe?

You will need:
- ability to launch new threads
- inter-thread communications (if you care)

Does anyone know the thread-safeness of the Lua libraries?



Ryan Bastic kirjoittaa torstaina, 19. kesäkuuta 2003, kello 03:56:

hello all,
i'm looking for a way to implement pre-emptive threading of multiple
lua scripts simultaneously in lua 5.... eg., given two lua scripts:

io.write("Hello world, FOO from ",_VERSION,"!\n")
io.write("Hello world, FOO from ",_VERSION,"!\n")
io.write("Hello world, FOO from ",_VERSION,"!\n")

and

io.write("Hello world, BAR from ",_VERSION,"!\n")
io.write("Hello world, BAR from ",_VERSION,"!\n")
io.write("Hello world, BAR from ",_VERSION,"!\n")

it'd be great to be able to execute a command of the nature:

$ lua5 hello.lua hello2.lua

and receive the output:

Hello world, FOO from _VERSION,!
Hello world, BAR from _VERSION,!
Hello world, FOO from _VERSION,!
Hello world, BAR from _VERSION,!
Hello world, FOO from _VERSION,!
Hello world, BAR from _VERSION,!

Someone mentioned there is a way to do this from C API. I would not like
to use coroutines. Interestingly enough, I've started to attempt to
accomplish this by modifying Lua 5 accordingly, but things are not going
too well :-) Anyone have any pointers?

-Ryan Bastic