From 5da0be08af9e7be8ab14c0fa4e49d788aaab3187 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Fri, 6 Mar 2020 15:41:53 -0500 Subject: [PATCH] updated files --- changes.md | 2 +- multi/init.lua | 38 ++++++++++++++++-------- multi/integration/lanesManager/init.lua | 17 ++++++----- test.dat | Bin 507 -> 0 bytes test.lua | 18 +++++++++-- 5 files changed, 51 insertions(+), 24 deletions(-) delete mode 100644 test.dat diff --git a/changes.md b/changes.md index c2cc9b0..7ce4fa0 100644 --- a/changes.md +++ b/changes.md @@ -4,7 +4,7 @@ Table of contents --- -# Update 14.2.0 - Destroy! +# Update 14.2.0 - Ending it all! Full Update Showcase --- ```lua diff --git a/multi/init.lua b/multi/init.lua index 3671406..6794a62 100644 --- a/multi/init.lua +++ b/multi/init.lua @@ -964,6 +964,12 @@ function multi:scheduleJob(time,func) end -- Threading stuff +local initT = false +local threadCount = 0 +local threadid = 0 +thread.__threads = {} +local threads = thread.__threads +local Gref = _G multi.GlobalVariables={} local dFunc = function() return true end local dRef = {nil,nil,nil} @@ -971,10 +977,20 @@ thread.requests = {} function thread.request(t,cmd,...) thread.requests[t.thread] = {cmd,{...}} end +function thread.getRunningThread() + local t = coroutine.running() + if t then + for i,v in pairs(threads) do + if t==v.thread then + return v + end + end + end +end function thread._Requests() local t = thread.requests[coroutine.running()] - thread.requests[coroutine.running()] = nil if t then + thread.requests[coroutine.running()] = nil local cmd,args = t[1],t[2] thread[cmd](unpack(args)) end @@ -984,6 +1000,7 @@ function thread.exec(func) end function thread.sleep(n) thread._Requests() + thread.getRunningThread().lastSleep = clock() dRef[1] = "_sleep_" dRef[2] = n or 0 return coroutine.yield(dRef) @@ -1150,17 +1167,6 @@ function thread.testFor(name,_val,sym) end) return thread.get(name) end -function multi.print(...) - if multi.defaultSettings.print then - print(...) - end -end -local initT = false -local threadCount = 0 -local threadid = 0 -thread.__threads = {} -local threads = thread.__threads -local Gref = _G function multi:newThread(name,func,...) multi.OnLoad:Fire() local func = func or name @@ -1468,6 +1474,8 @@ function multi:newService(func) -- Priority managed threads elseif math.abs(n)==2 then ap = math.abs(p-1)*32+1 task = thread.skip + elseif math.abs(n)==3 then + -- This is a time based pirority manager. Things that take long to run get end return c end @@ -2261,6 +2269,12 @@ else thread.__CORES=tonumber(io.popen("nproc --all"):read("*n")) end +function multi.print(...) + if multi.defaultSettings.print then + print(...) + end +end + multi.GetType=multi.getType multi.IsPaused=multi.isPaused multi.IsActive=multi.isActive diff --git a/multi/integration/lanesManager/init.lua b/multi/integration/lanesManager/init.lua index 62d35da..995cf0e 100644 --- a/multi/integration/lanesManager/init.lua +++ b/multi/integration/lanesManager/init.lua @@ -84,16 +84,17 @@ function multi:newSystemThread(name, func, ...) c.priority = THREAD.Priority_Normal local args = {...} multi:newThread(function() - print("I am here!") c.thread = lanes.gen(table.concat(c.loadString,","), { - globals={ - THREAD_NAME=name, - THREAD_ID=count, - THREAD = THREAD, - GLOBAL = GLOBAL, - _Console = __ConsoleLinda - },priority=c.priority}, func)(unpack(args)) + globals={ -- Set up some globals + THREAD_NAME=name, + THREAD_ID=count, + THREAD = THREAD, + GLOBAL = GLOBAL, + _Console = __ConsoleLinda + }, + priority=c.priority + },func)(unpack(args)) thread.kill() end) count = count + 1 diff --git a/test.dat b/test.dat deleted file mode 100644 index 1bff5741abc2ac064de4ebae49d585bdf589ee53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 507 zcmc(a&1wQM5XUDmt61^cOHZD9DIUE^i-&&bb}8Mwz@j5vh)LLu2OqceQhW;kAr_Vv zyf$Gn-;?>}T3!=TSt@<-Jc7BaYU>-f=C+k^zahDnpRq{yw|l$RuY(lBi&(~X!%a6- z^jZ!gW^u|wnR?5~iS@&J=Uo#j8@fGukVe0EgA4V+W`iCTlLcmAlP9R+F^-=@Zt|t1 z;X~jyOwGQ!Ba*l(>&Y3iw?fc@q*#%l(K8$4CRe_xZ4g2L?o6GbG8pIl5e9zvg8FCH ax3tL%RARk{^^0}-!`lDDI!>&Ui?k