Skip to content

Commit

Permalink
lib.ptree.worker: reformulate to use engine.main with done func
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Nov 2, 2018
1 parent a6def7b commit 8201d1d
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/lib/ptree/worker.lua
Expand Up @@ -92,27 +92,22 @@ function Worker:handle_actions_from_manager()
end

function Worker:main ()
local vmprofile = require("jit.vmprofile")
local stop = engine.now() + self.duration
local next_time = engine.now()

-- Setup vmprofile.
engine.setvmprofile("engine")
vmprofile.start()

if not engine.auditlog_enabled then engine.enable_auditlog() end

repeat
self.breathe()
local function control ()
if next_time < engine.now() then
next_time = engine.now() + self.period
engine.setvmprofile("worker")
self:handle_actions_from_manager()
timer.run()
engine.setvmprofile("engine")
end
if stop < engine.now() then
return true -- done
end
if not engine.busywait then engine.pace_breathing() end
until stop < engine.now()
counter.commit()
if not self.no_report then engine.report(self.report) end
end

engine.main{done=control}
end

function main (opts)
Expand Down

0 comments on commit 8201d1d

Please sign in to comment.