Software /
code /
prosody
Comparison
util/timer.lua @ 2366:c3a364342cb4
util.timer: Use luaevent's built-in method of repeating an event (fixes a weird crash)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 17 Dec 2009 16:52:39 +0000 |
parent | 2098:a1ad06f1c090 |
child | 2925:692b3c6c5bd2 |
comparison
equal
deleted
inserted
replaced
2365:0bd8408a491c | 2366:c3a364342cb4 |
---|---|
53 end | 53 end |
54 end); | 54 end); |
55 else | 55 else |
56 local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1; | 56 local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1; |
57 function _add_task(delay, func) | 57 function _add_task(delay, func) |
58 event_base:addevent(nil, event.EV_TIMEOUT, function () | 58 event_base:addevent(nil, 0, function () |
59 local ret = func(); | 59 local ret = func(); |
60 if ret then | 60 if ret then |
61 _add_task(ret, func); | 61 return 0, ret; |
62 else | 62 else |
63 return EVENT_LEAVE; | 63 return EVENT_LEAVE; |
64 end | 64 end |
65 end | 65 end |
66 , delay); | 66 , delay); |