From 37c70c3365b2505265961d0ad8d95973dfaa0793 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Sat, 30 Sep 2017 02:13:27 +0200 Subject: [PATCH] First building API of promises and error handling * Currently not functional (yet) --- include/continuable/continuable-base.hpp | 42 +---- .../continuable/continuable-promise-base.hpp | 12 +- include/continuable/continuable-trait.hpp | 76 +++++++++ include/continuable/continuable.hpp | 23 +-- include/continuable/detail/base.hpp | 147 ++++++++++-------- include/continuable/detail/types.hpp | 63 ++++++++ test/playground/CMakeLists.txt | 2 + test/playground/test-playground.cpp | 26 +++- 8 files changed, 274 insertions(+), 117 deletions(-) create mode 100644 include/continuable/continuable-trait.hpp create mode 100644 include/continuable/detail/types.hpp diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index 74781fa..25920f1 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -42,6 +42,7 @@ #include #include #include +#include #include namespace cti { @@ -192,9 +193,9 @@ public: /// ``` /// /// \since version 1.0.0 - template + template auto then(T&& callback, - E&& executor = detail::base::this_thread_executor_tag{}) && { + E&& executor = detail::types::this_thread_executor_tag{}) && { return detail::base::chain_continuation(std::move(*this).materialize(), std::forward(callback), std::forward(executor)); @@ -262,12 +263,12 @@ public: /// /// /// \since version 2.0.0 - template + template auto catching(T&& callback, - E&& executor = detail::base::this_thread_executor_tag{}) && { - /*return detail::base::chain_continuation(std::move(*this).materialize(), - std::forward(callback), - std::forward(executor));*/ + E&& executor = detail::types::this_thread_executor_tag{}) && { + return detail::base::chain_error_handler(std::move(*this).materialize(), + std::forward(callback), + std::forward(executor)); } /// Invokes both continuable_base objects parallel and calls the @@ -627,33 +628,6 @@ auto when_seq(Continuables&&... continuables) { return detail::traits::fold(detail::traits::seq_folding(), std::forward(continuables)...); } - -/// Trait to retrieve a continuable_base type with a given type-erasure backend. -/// -/// Every object may me used as type-erasure backend as long as the -/// requirements of a `std::function` like wrapper are satisfied. -/// -/// \tparam CallbackWrapper The type which is used to erase the callback. -/// -/// \tparam ContinuationWrapper The type which is used to erase the -/// continuation data. -/// -/// \tparam Args The current signature of the continuable. -template