aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-23 14:22:01 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-23 14:22:01 +0000
commit072c04815b67ca8f184e83b73ceea2f106853e24 (patch)
treebd680ccb362413e1f653a1d4f4ae89db6192b70e
parent59e03259d1126b6c0bb3a2c2cdea4f967bb23bd8 (diff)
downloadprosody-072c04815b67ca8f184e83b73ceea2f106853e24.tar.gz
prosody-072c04815b67ca8f184e83b73ceea2f106853e24.zip
util.async: Remove async.once(), can now be replaced by runner():run(func)
-rw-r--r--spec/util_async_spec.lua19
-rw-r--r--util/async.lua14
2 files changed, 0 insertions, 33 deletions
diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua
index d81b18b5..d2de8c94 100644
--- a/spec/util_async_spec.lua
+++ b/spec/util_async_spec.lua
@@ -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);
diff --git a/util/async.lua b/util/async.lua
index 9456874d..52d2c99c 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -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);