From: Nathaniel Wesley Filardo Date: Sat, 29 Jul 2017 19:32:45 +0000 (-0400) Subject: tq bugfixes (and API change) X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=48e6ed5e2042cfc24d8899d4a8838fd74d1814eb;p=acmetensortoys-esp-lua_lamp tq bugfixes (and API change) - not all lapsed time should be credited to the head node - needs to reset the time base (_tst) in all cases - always return the object for cancellation - defend against time going backwards (just in case) While here, rework to simplify, simplify API, and add comments --- diff --git a/linux-draw.lua b/linux-draw.lua index cceffe1..e9cb104 100644 --- a/linux-draw.lua +++ b/linux-draw.lua @@ -29,10 +29,10 @@ end tq = dofile("tq/tq.lua")(nil) tq.__emu_lastcb = 0 tq.now = function() return cq.monotime() * 1000000 end -tq.arm = function(self,fn,t) +tq.arm = function(self,t,et) local cbix = tq.__emu_lastcb + 1 tq.__emu_lastcb = cbix - cqc:wrap(function() cq.poll(t/1000) ; if tq.__emu_lastcb == cbix then fn() end end) + cqc:wrap(function() cq.poll(t/1000) ; if tq.__emu_lastcb == cbix then tq:fire() end end) end -- how backwards is this!? We are using tq as faked above for tmr support