multi/multi/threading/updater.lua
Ryan 6b3e0b5f9b Added ThreaderUpdater
Added the threadedupdater module and updated the all.lua to reflect the new additions!
2017-06-06 16:45:23 -04:00

33 lines
601 B
Lua

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