modified test file

This commit is contained in:
Ryan Ward 2020-01-30 14:39:09 -05:00
parent 2521a90712
commit 0446dd0bea

View File

@ -1,16 +1,17 @@
package.path="?/init.lua;?.lua;"..package.path package.path="?/init.lua;?.lua;"..package.path
multi,thread = require("multi"):init() multi,thread = require("multi"):init()
function test() -- Auto converts your function into a threaded function test = thread:newFunction(function()
thread.sleep(1) thread.sleep(1)
return 1,2 return 1,2
end end)
multi:newThread(function() multi:newThread(function()
while true do while true do
thread.sleep(.1) thread.sleep(.1)
print("hi") print("hi")
end end
end) end)
c,d = test() -- When not in a threaded enviroment at root level we need to tell the code that we are waiting!
c,d = test().wait()
print(c,d) print(c,d)
a,b = 6,7 a,b = 6,7
multi:newThread(function() multi:newThread(function()
@ -26,4 +27,7 @@ multi:newThread(function()
end) end)
-- This waits for the returns since we are demanding them -- This waits for the returns since we are demanding them
end) end)
multi.OnExit(function(n)
print("Code Exited")
end)
multi:mainloop() multi:mainloop()