mirror of
https://github.com/bjc/prosody.git
synced 2025-04-05 22:27:38 +03:00
util.async: Add helper methods for setting watchers
This commit is contained in:
parent
d62d872cd3
commit
eb96155cf3
1 changed files with 16 additions and 0 deletions
|
@ -215,12 +215,28 @@ end
|
|||
function runner_mt:enqueue(input)
|
||||
table.insert(self.queue, input);
|
||||
self:log("debug", "queued new work item, %d items queued", #self.queue);
|
||||
return self;
|
||||
end
|
||||
|
||||
function runner_mt:log(level, fmt, ...)
|
||||
return log(level, "[runner %s] "..fmt, self.id, ...);
|
||||
end
|
||||
|
||||
function runner_mt:onready(f)
|
||||
self.watchers.ready = f;
|
||||
return self;
|
||||
end
|
||||
|
||||
function runner_mt:onwaiting(f)
|
||||
self.watchers.waiting = f;
|
||||
return self;
|
||||
end
|
||||
|
||||
function runner_mt:onerror(f)
|
||||
self.watchers.error = f;
|
||||
return self;
|
||||
end
|
||||
|
||||
local function ready()
|
||||
return pcall(checkthread);
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue