V15.2.0 #33

Merged
rayaman merged 75 commits from v15.2.0 into master 2022-04-19 18:45:52 -04:00
3 changed files with 13 additions and 47 deletions
Showing only changes of commit b74a6c006e - Show all commits

View File

@ -1197,7 +1197,7 @@ function thread:newFunctionBase(generator,holdme)
end end
} }
end end
local t = generator(...) --multi.getCurrentProcess():newThread("TempThread",func,...) local t = generator(...)
t.OnDeath(function(self,status,...) rets = {...} end) t.OnDeath(function(self,status,...) rets = {...} end)
t.OnError(function(self,e) err = e end) t.OnError(function(self,e) err = e end)
if holdme then if holdme then
@ -1209,6 +1209,9 @@ function thread:newFunctionBase(generator,holdme)
OnReturn = multi:newConnection(), OnReturn = multi:newConnection(),
isTFunc = true, isTFunc = true,
wait = wait, wait = wait,
getReturns = function()
return unpack(rets)
end,
connect = function(f) connect = function(f)
local tempConn = multi:newConnection() local tempConn = multi:newConnection()
t.OnDeath(function(self,status,...) if f then f(...) else tempConn:Fire(...) end end) t.OnDeath(function(self,status,...) if f then f(...) else tempConn:Fire(...) end end)

View File

@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
]] ]]
package.path = "?/init.lua;?.lua;" .. package.path package.path = "?/init.lua;?.lua;" .. package.path
local multi, thread = require("multi"):init() -- get it all and have it on all lanes multi, thread = require("multi"):init() -- get it all and have it on all lanes
if multi.integration then -- This allows us to call the lanes manager from supporting modules without a hassle if multi.integration then -- This allows us to call the lanes manager from supporting modules without a hassle
return { return {
init = function() init = function()
@ -57,7 +57,6 @@ local GLOBAL,THREAD = require("multi.integration.lanesManager.threads").init(__G
local count = 1 local count = 1
local started = false local started = false
local livingThreads = {} local livingThreads = {}
local threads = {}
function THREAD:newFunction(func,holdme) function THREAD:newFunction(func,holdme)
return thread:newFunctionBase(function(...) return thread:newFunctionBase(function(...)
@ -69,7 +68,7 @@ function multi:newSystemThread(name, func, ...)
multi.InitSystemThreadErrorHandler() multi.InitSystemThreadErrorHandler()
local rand = math.random(1, 10000000) local rand = math.random(1, 10000000)
local return_linda = lanes.linda() local return_linda = lanes.linda()
local c = {} c = {}
c.name = name c.name = name
c.Name = name c.Name = name
c.Id = count c.Id = count
@ -94,12 +93,10 @@ function multi:newSystemThread(name, func, ...)
local has_error = true local has_error = true
return_linda:set("returns",{func(...)}) return_linda:set("returns",{func(...)})
has_error = false has_error = false
print("Thread ending")
end)(...) end)(...)
count = count + 1 count = count + 1
function c:kill() function c:kill()
self.thread:cancel() self.thread:cancel()
multi.print("Thread: '" .. self.name .. "' has been stopped!")
self.alive = false self.alive = false
end end
table.insert(multi.SystemThreads, c) table.insert(multi.SystemThreads, c)
@ -108,7 +105,6 @@ function multi:newSystemThread(name, func, ...)
GLOBAL["__THREADS__"] = livingThreads GLOBAL["__THREADS__"] = livingThreads
return c return c
end end
function multi.InitSystemThreadErrorHandler() function multi.InitSystemThreadErrorHandler()
if started == true then if started == true then
return return

View File

@ -1,52 +1,19 @@
package.path = "./?/init.lua;"..package.path
local multi,thread = require("multi"):init() local multi,thread = require("multi"):init()
local GLOBAL,THREAD = require("multi.integration.threading"):init() local GLOBAL,THREAD = require("multi.integration.threading"):init()
function sleep(n) function sleep(n)
if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end
end end
-- local GLOBAL,THREAD = {},{}-- require("multi.integration.lanesManager.threads").init(__GlobalLinda,__SleepingLinda)
-- local count = 1
-- local started = false
-- local livingThreads = {}
-- local threads = {}
-- multi.SystemThreads = {}
-- function multi:newSystemThread(name, func, ...)
-- --multi.InitSystemThreadErrorHandler()
-- local rand = math.random(1, 10000000)
-- local return_linda = lanes.linda()
-- local c = {}
-- c.name = name
-- c.Name = name
-- c.Id = count
-- c.loadString = {"base","package","os","io","math","table","string","coroutine"}
-- livingThreads[count] = {true, name}
-- c.returns = return_linda
-- c.Type = "sthread"
-- c.creationTime = os.clock()
-- c.alive = true
-- c.priority = THREAD.Priority_Normal
-- c.thread = lanes.gen("*",func)(...)
-- count = count + 1
-- function c:kill()
-- self.thread:cancel()
-- multi.print("Thread: '" .. self.name .. "' has been stopped!")
-- self.alive = false
-- end
-- table.insert(multi.SystemThreads, c)
-- c.OnDeath = multi:newConnection()
-- c.OnError = multi:newConnection()
-- GLOBAL["__THREADS__"] = livingThreads
-- return c
-- end
multi:newSystemThread("test",function() func = THREAD:newFunction(function(a,b,c)
print("Hello World!") print("Hello Thread!",a,b,c)
return 1,2,3
end) end)
multi:newThread("Test thread",function() multi:newThread("Test thread",function()
while true do handler = func(4,5,6)
thread.sleep(1) thread.hold(handler.OnReturn)
print("...") print("Function Done",handler.getReturns())
end
end) end)
multi:mainloop() multi:mainloop()