mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.async: Remove async.once(), can now be replaced by runner():run(func)
This commit is contained in:
parent
59e03259d1
commit
072c04815b
2 changed files with 0 additions and 33 deletions
|
@ -613,23 +613,4 @@ describe("util.async", function()
|
|||
assert.spy(r.watchers.error).was_not.called();
|
||||
end);
|
||||
end);
|
||||
|
||||
describe("#once()", function ()
|
||||
it("should work", function ()
|
||||
local f = spy.new(function ()
|
||||
assert.truthy(async.ready());
|
||||
end);
|
||||
async.once(f);
|
||||
assert.spy(f).was.called();
|
||||
assert.spy(f).was.called_with();
|
||||
end);
|
||||
it("should propagate errors", function ()
|
||||
local function should_error()
|
||||
async.once(function ()
|
||||
error("hello world");
|
||||
end);
|
||||
end;
|
||||
assert.error_matches(should_error, "hello world");
|
||||
end);
|
||||
end);
|
||||
end);
|
||||
|
|
|
@ -226,20 +226,6 @@ local function ready()
|
|||
return pcall(checkthread);
|
||||
end
|
||||
|
||||
local once; -- forward declaration
|
||||
do
|
||||
local once_watchers = {
|
||||
error = function (_, err)
|
||||
error(err);
|
||||
end;
|
||||
};
|
||||
local function once_runner(func) func(); end
|
||||
function once(func)
|
||||
local r = runner(once_runner, once_watchers);
|
||||
return r:run(func);
|
||||
end
|
||||
end
|
||||
|
||||
local function sleep(s)
|
||||
local wait, done = waiter();
|
||||
timer.add_task(s, done);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue