Comparison

util/watchdog.lua @ 12547:e79c64b2dfed

util.watchdog: Allow passing a new timeout to :reset()
author Matthew Wild <mwild1@gmail.com>
date Sat, 11 Jun 2022 22:15:31 +0100
parent 12546:e78b35574aae
child 12975:d10957394a3c
comparison
equal deleted inserted replaced
12546:e78b35574aae 12547:e79c64b2dfed
17 watchdog:reset(); -- Kick things off 17 watchdog:reset(); -- Kick things off
18 18
19 return watchdog; 19 return watchdog;
20 end 20 end
21 21
22 function watchdog_methods:reset() 22 function watchdog_methods:reset(new_timeout)
23 if new_timeout then
24 self.timeout = new_timeout;
25 end
23 if self.timer_id then 26 if self.timer_id then
24 timer.reschedule(self.timer_id, self.timeout+1); 27 timer.reschedule(self.timer_id, self.timeout+1);
25 else 28 else
26 self.timer_id = timer.add_task(self.timeout+1, function () 29 self.timer_id = timer.add_task(self.timeout+1, function ()
27 return self:callback(); 30 return self:callback();