# HG changeset patch # User Matthew Wild # Date 1521814921 0 # Node ID 867ac771fb6e451c18a328d906dff87ae7e72974 # Parent 151ecd18d624a33c4541a2a3711abb9585050b2a util.async: Remove async.once(), can now be replaced by runner():run(func) diff -r 151ecd18d624 -r 867ac771fb6e spec/util_async_spec.lua --- a/spec/util_async_spec.lua Fri Mar 23 14:18:27 2018 +0000 +++ b/spec/util_async_spec.lua Fri Mar 23 14:22:01 2018 +0000 @@ -613,23 +613,4 @@ 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 -r 151ecd18d624 -r 867ac771fb6e util/async.lua --- a/util/async.lua Fri Mar 23 14:18:27 2018 +0000 +++ b/util/async.lua Fri Mar 23 14:22:01 2018 +0000 @@ -226,20 +226,6 @@ 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);