]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: refactor crimson::do_until() 37953/head
authorKefu Chai <kchai@redhat.com>
Thu, 5 Nov 2020 04:46:52 +0000 (12:46 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 5 Nov 2020 04:52:35 +0000 (12:52 +0800)
* define `errorator_t` instead of `futurator` to simplify the code a
  little bit.
* use seastar helper function / types when appropriate

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/errorator.h

index 7c6f9fe20ad394a2c20575b9db4fe49461d0a7d0..002c158dc7f8f1197d1f8157bd03accf86ffbe80 100644 (file)
@@ -49,24 +49,24 @@ inline auto do_for_each(Container& c, AsyncAction action) {
 
 template<typename AsyncAction>
 inline auto do_until(AsyncAction action) {
-  using futurator = \
-    ::seastar::futurize<std::result_of_t<AsyncAction()>>;
+  using errorator_t =
+    typename ::seastar::futurize_t<std::invoke_result_t<AsyncAction>>::errorator_type;
 
   while (true) {
-    auto f = futurator::invoke(action);
+    auto f = ::seastar::futurize_invoke(action);
     if (f.failed()) {
-      return futurator::type::errorator_type::template make_exception_future2<>(
+      return errorator_t::template make_exception_future2<>(
         f.get_exception()
       );
     } else if (f.available()) {
       if (auto done = f.get0()) {
-        return futurator::type::errorator_type::template make_ready_future<>();
+        return errorator_t::template make_ready_future<>();
       }
     } else {
       return std::move(f)._then(
         [action = std::move(action)] (auto &&done) mutable {
           if (done) {
-            return futurator::type::errorator_type::template make_ready_future<>();
+            return errorator_t::template make_ready_future<>();
           }
           return ::crimson::do_until(
             std::move(action));