mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Added ThreaderUpdater
Added the threadedupdater module and updated the all.lua to reflect the new additions!
This commit is contained in:
@@ -15,3 +15,4 @@ require("multi.threading.loop")
|
||||
require("multi.threading.process")
|
||||
require("multi.threading.step")
|
||||
require("multi.threading.tstep")
|
||||
require("multi.threading.updater")
|
||||
@@ -1,5 +1,6 @@
|
||||
require("multi.threading.step")
|
||||
require("multi.threading.tstep")
|
||||
require("multi.threading.updater")
|
||||
require("multi.threading.alarm")
|
||||
require("multi.threading.loop")
|
||||
require("multi.threading.event")
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
require("multi.threading")
|
||||
function multi:newThreadedUpdater(name,skip)
|
||||
local c=self:newTBase()
|
||||
c.Type='updaterThread'
|
||||
c.pos=1
|
||||
c.skip=skip or 1
|
||||
function c:Resume()
|
||||
self.rest=false
|
||||
end
|
||||
function c:Pause()
|
||||
self.rest=true
|
||||
end
|
||||
c.OnUpdate=self.OnMainConnect
|
||||
c.rest=false
|
||||
c.updaterate=0
|
||||
c.restRate=.75
|
||||
multi:newThread(name,function(ref)
|
||||
while true do
|
||||
if c.rest then
|
||||
thread.sleep(c.restRate) -- rest a bit more when a thread is paused
|
||||
else
|
||||
for i=1,#c.func do
|
||||
c.func[i](c)
|
||||
end
|
||||
c.pos=c.pos+1
|
||||
thread.skip(c.skip)
|
||||
end
|
||||
end
|
||||
end)
|
||||
self:create(c)
|
||||
return c
|
||||
end
|
||||
Reference in New Issue
Block a user