From 6d0e136bae8e2e8bbd56a0ce46b9fac8aeff4bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Thu, 23 May 2019 16:36:08 +0200 Subject: [PATCH] Concurrent.Future: Added query_{success,failure}_callbacks(). --- lib/modules/Concurrent.pmod | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/modules/Concurrent.pmod b/lib/modules/Concurrent.pmod index dfd4b95263..a78730beb9 100644 --- a/lib/modules/Concurrent.pmod +++ b/lib/modules/Concurrent.pmod @@ -207,7 +207,7 @@ class Future //! @[cb] will always be called from the main backend. //! //! @seealso - //! @[on_failure()] + //! @[on_failure()], @[query_success_callbacks()] this_program on_success(function(mixed, mixed ... : void) cb, mixed ... extra) { switch (state) { @@ -223,6 +223,18 @@ class Future return this_program::this; } + //! Query the set of active success callbacks. + //! + //! @returns + //! Returns an array with callback functions. + //! + //! @seealso + //! @[on_success()], @[query_failure_callbacks()] + array(function) query_success_callbacks() + { + return column(success_cbs, 0); + } + //! Register a callback that is to be called on failure. //! //! @param cb @@ -237,7 +249,7 @@ class Future //! @[cb] will always be called from the main backend. //! //! @seealso - //! @[on_success()] + //! @[on_success()], @[query_failure_callbacks()] this_program on_failure(function(mixed, mixed ... : void) cb, mixed ... extra) { switch (state) { @@ -256,6 +268,18 @@ class Future return this_program::this; } + //! Query the set of active failure callbacks. + //! + //! @returns + //! Returns an array with callback functions. + //! + //! @seealso + //! @[on_failure()], @[query_success_callbacks()] + array(function) query_failure_callbacks() + { + return column(failure_cbs, 0); + } + //! Apply @[fun] with @[val] followed by the contents of @[ctx], //! and update @[p] with the result. protected void apply(mixed val, Promise p, -- GitLab