Xfel, on 25 April 2012 - 01:53 PM, said:
Cloudy, on 25 April 2012 - 12:19 PM, said:
The parallel API is how you should do multi threading - the API uses coroutines. The bios in fact calls a coroutine for rednet at the same time as the shell.
I don't think a fork function is necessary - parallel works perfectly fine.
If you want some kind of background program, you need it. And that can't be done with parallel.
Really?
while true do
parallel.waitForAny(yourBackgroundFunc(), function() shell.run("shell") end)
end
There, backgrounded process which runs while shell does. Not to mention you can code this in Lua without a built in function - I know a person who has coded his own OS replacement complete with background processes, all without editing bios.lua.
OminousPenguin, on 25 April 2012 - 03:54 PM, said:
Anyway. The Lua is compiled into Java bytecode and Java does support threads and synchronisation. The fact that Lua doesn't is irrelevant. I don't know how good a programmer the author of CC is and I'm not going to make any assumptions about whether he'd be able to implement it error free. The fact is that it would be possible.
It wouldn't be worth the effort - Lua is not designed to be multi threaded apart from coroutines and he would have to substantially change it.