Software /
code /
prosody
Changeset
6931:5c2c8aeb4690
util.timer: Expire timer instance if another instance is already set to take care of the next scheduled event
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 22 Nov 2015 17:20:20 +0100 |
parents | 6930:58e260832334 |
children | 6932:f5fd2c5cdf28 |
files | util/timer.lua |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/timer.lua Sun Nov 22 17:18:29 2015 +0100 +++ b/util/timer.lua Sun Nov 22 17:20:20 2015 +0100 @@ -43,8 +43,17 @@ params[_id] = _param; end end - next_time = peek; - if peek ~= nil then + + if peek ~= nil and _active_timers > 1 and peek == next_time then + -- Another instance of _on_timer already set next_time to the same value, + -- so it should be safe to not renew this timer event + peek = nil; + else + next_time = peek; + end + + if peek then + -- peek is the time of the next event return peek - now; end _active_timers = _active_timers - 1;