Software /
code /
prosody
Comparison
util/timer.lua @ 4385:c94167139f27
util.timer: Fix corner case of timer not repeating if it returns <= 0
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Sep 2011 15:48:56 +0100 |
parent | 3683:c2158221e2e6 |
child | 4413:ffa4bed1b716 |
comparison
equal
deleted
inserted
replaced
4384:7fbcb7e6a6a0 | 4385:c94167139f27 |
---|---|
30 local current_time = get_time(); | 30 local current_time = get_time(); |
31 delay = delay + current_time; | 31 delay = delay + current_time; |
32 if delay >= current_time then | 32 if delay >= current_time then |
33 t_insert(new_data, {delay, func}); | 33 t_insert(new_data, {delay, func}); |
34 else | 34 else |
35 func(); | 35 local r = func(); |
36 if r and type(r) == "number" then | |
37 return _add_task(r, func); | |
38 end | |
36 end | 39 end |
37 end | 40 end |
38 | 41 |
39 ns_addtimer(function() | 42 ns_addtimer(function() |
40 local current_time = get_time(); | 43 local current_time = get_time(); |