aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_event.lua
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-10-20 16:13:24 -0400
committerdaurnimator <quae@daurnimator.com>2014-10-20 16:13:24 -0400
commitdcd855afaa62797fc8285ff4a7a8e1a8f6279a1f (patch)
tree032ae646f40566f31102c4e76aacd8f843181945 /net/server_event.lua
parentf0f0c0393ca2c0f6645fc2055c8e4aeffdac4225 (diff)
downloadprosody-dcd855afaa62797fc8285ff4a7a8e1a8f6279a1f.tar.gz
prosody-dcd855afaa62797fc8285ff4a7a8e1a8f6279a1f.zip
Move timer code out of util.timer and into relevant net.server backends
Diffstat (limited to 'net/server_event.lua')
-rw-r--r--net/server_event.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/server_event.lua b/net/server_event.lua
index 480d876d..fa6dda19 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -848,6 +848,23 @@ local function link(sender, receiver, buffersize)
sender:set_mode("*a");
end
+local add_task do
+ local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1;
+ local socket_gettime = socket.gettime
+ function add_task(delay, callback)
+ local event_handle;
+ event_handle = base:addevent(nil, 0, function ()
+ local ret = callback(socket_gettime());
+ if ret then
+ return 0, ret;
+ elseif event_handle then
+ return EVENT_LEAVE;
+ end
+ end
+ , delay);
+ end
+end
+
return {
cfg = cfg,
@@ -864,6 +881,7 @@ return {
closeall = closeallservers,
get_backend = get_backend,
hook_signal = hook_signal,
+ add_task = add_task,
__NAME = SCRIPT_NAME,
__DATE = LAST_MODIFIED,