Two simultaneous routines

4

How do I run two routines simultaneously in the same program? I'm trying to download a file, and print a value while downloading. Exactly this:

http = require "socket.http"
function downloadFile(url)
download = http.request(url)
return download
end
repeat
print("--")
until downloadFile("http://pokedg/patch/1.7z")

But only returns:

--

And it ends.

    
asked by anonymous 24.11.2014 / 09:32

1 answer

5

Moon does not allow pre-emptive multitasking, only corotines, which are multi-tasking collaborative.

Unless the socket.http library allows concurrent downloads, the only solution is to execute fully separate Lua states on separate threads. (Operating system threads, not Lua.)

    
24.11.2014 / 10:43