From abbfd9ba88b58660db125b2facbe8f070302b357 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 13 Sep 2019 00:39:40 +0200 Subject: [PATCH] crimson: decouple errorator from unthrowable_wrapper. Signed-off-by: Radoslaw Zarzynski --- src/crimson/common/errorator.h | 64 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 411a3b97912..4fa1e22d402 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -100,7 +100,7 @@ public: } }; -template +template struct errorator { template class future : private seastar::future { @@ -144,24 +144,24 @@ struct errorator { struct make_errorator { // NOP. The generic template. }; - template - struct make_errorator, + struct make_errorator, ErrorVisitorRetsHeadT, ErrorVisitorRetsTailT...> { using type = std::conditional_t< is_error_v, - typename make_errorator, ErrorVisitorRetsTailT...>::type, - typename make_errorator, + typename make_errorator, ErrorVisitorRetsTailT...>::type>; }; // finish the recursion - template - struct make_errorator> { - using type = ::ceph::errorator; + template + struct make_errorator> { + using type = ::crimson::errorator; }; template using make_errorator_t = typename make_errorator::type; @@ -169,7 +169,7 @@ struct errorator { using base_t::base_t; public: - using errorator_type = ceph::errorator; + using errorator_type = ::crimson::errorator; [[gnu::always_inline]] future(base_t&& base) @@ -182,7 +182,7 @@ struct errorator { operator ErroratedFuture () && { using dest_errorator_t = \ typename ErroratedFuture::errorator_type; - using this_errorator_t = errorator; + using this_errorator_t = errorator; static_assert(!dest_errorator_t::template is_less_errorated_v, "conversion is possible to more-or-eq errorated future!"); @@ -215,19 +215,21 @@ struct errorator { // TODO: we don't really need to `make_exception_ptr` each time. It still // allocates memory underneath while can be replaced with single instance // per type created on start-up. - template <_impl::ct_error ErrorV> - future(const unthrowable_wrapper& e) - : base_t(seastar::make_exception_future(exception>{})) { - // this is `fold expression` of C++17 - static_assert((... || (std::is_same_v, - WrappedAllowedErrorsT>)), - "disallowed ct_error"); + template , + bool IsError = is_error_v, + class = std::enable_if_t> + future(ErrorT&&) + : base_t(seastar::make_exception_future(exception{})) { + // this is `fold expression` of C++17. + static_assert((... || (std::is_same_v)), + "ErrorT is not enlisted in errorator"); } template auto safe_then(ValueFuncT&& valfunc, ErrorVisitorT&& errfunc) { static_assert((... && std::is_invocable_v), + AllowedErrors>), "provided Error Visitor is not exhaustive"); using value_func_result_t = std::invoke_result_t; @@ -240,8 +242,7 @@ struct errorator { // to next continuation. using return_errorator_t = make_errorator_t< value_func_errorator_t, - std::decay_t>...>; + std::decay_t>...>; // OK, now we know about all errors next continuation must take // care about. If Visitor handled everything and the Value Func // doesn't return any, we'll finish with errorator<>::future @@ -265,7 +266,7 @@ struct errorator { std::forward(errfunc), std::move(future).get_exception() ); - (maybe_handle_error.template handle() , ...); + (maybe_handle_error.template handle() , ...); return plainify(std::move(maybe_handle_error).get_result()); } else { return plainify(futurator_t::apply(std::forward(valfunc), @@ -281,7 +282,7 @@ struct errorator { private: // for the sake of `plainify()` let any errorator convert errorated // future into plain one. - template + template friend class errorator; base_t&& as_plain_future() && { @@ -294,7 +295,7 @@ struct errorator { template decltype(auto) operator()(ErrorT&& e) { using decayed_t = std::decay_t; - static_assert((... || std::is_same_v), + static_assert((... || std::is_same_v), "passing further disallowed ErrorT"); return std::forward(e); } @@ -303,7 +304,7 @@ struct errorator { struct discard_all { template decltype(auto) operator()(ErrorT&&) { - static_assert((... || std::is_same_v>), "discarding disallowed ErrorT"); return ignore_marker_t{}; @@ -311,15 +312,14 @@ struct errorator { }; // get a new errorator by extending current one with new error - template - using extend = errorator; + template + using extend = errorator; // comparing errorators template struct is_carried { static constexpr bool value = \ - ((std::is_same_v) || ...); + ((std::is_same_v) || ...); }; template static constexpr bool is_carried_v = is_carried::value; @@ -328,10 +328,10 @@ struct errorator { struct is_less_errorated { // NOP. }; - template - struct is_less_errorated> { + template + struct is_less_errorated> { static constexpr bool value = \ - ((!is_carried_v) || ...); + ((!is_carried_v) || ...); }; template static constexpr bool is_less_errorated_v = \ @@ -379,7 +379,7 @@ private: std::void_t< typename ErroratedFutureT::errorator_type>> { public: - using type = ::ceph::errorator::future; + using type = ::crimson::errorator::future; template static type apply(Func&& func, std::tuple&& args) { -- 2.39.5