Software /
code /
prosody
Comparison
util/timer.lua @ 2098:a1ad06f1c090
util.timer: Fix libevent timers (event.base doesn't exist...)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 03:16:14 +0000 |
parent | 2095:3256c5d00901 |
child | 2366:c3a364342cb4 |
comparison
equal
deleted
inserted
replaced
2097:642806f67b75 | 2098:a1ad06f1c090 |
---|---|
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 local ns_addtimer = require "net.server".addtimer; | 10 local ns_addtimer = require "net.server".addtimer; |
11 local event = require "net.server".event; | 11 local event = require "net.server".event; |
12 local event_base = require "net.server".event_base; | |
12 | 13 |
13 local get_time = os.time; | 14 local get_time = os.time; |
14 local t_insert = table.insert; | 15 local t_insert = table.insert; |
15 local t_remove = table.remove; | 16 local t_remove = table.remove; |
16 local ipairs, pairs = ipairs, pairs; | 17 local ipairs, pairs = ipairs, pairs; |
52 end | 53 end |
53 end); | 54 end); |
54 else | 55 else |
55 local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1; | 56 local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1; |
56 function _add_task(delay, func) | 57 function _add_task(delay, func) |
57 event.base:addevent(nil, event.EV_TIMEOUT, function () | 58 event_base:addevent(nil, event.EV_TIMEOUT, function () |
58 local ret = func(); | 59 local ret = func(); |
59 if ret then | 60 if ret then |
60 _add_task(ret, func); | 61 _add_task(ret, func); |
61 else | 62 else |
62 return EVENT_LEAVE; | 63 return EVENT_LEAVE; |