]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: drop ceph::do_with(). Specialize sestar::do_with() instead.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 17 Oct 2019 08:56:22 +0000 (10:56 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 20 Nov 2019 19:37:44 +0000 (20:37 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/errorator.h
src/crimson/osd/pg.cc

index fa532cd69dc4e2d72bf965be7a648fac528e9639..d07c48c7d5a686f939e9d2b36f2da24d0f5a4a8e 100644 (file)
@@ -43,19 +43,6 @@ inline auto do_for_each(Container& c, AsyncAction action) {
   return ::crimson::do_for_each(std::begin(c), std::end(c), std::move(action));
 }
 
-template<typename T, typename F>
-static inline auto do_with(T&& rvalue, F&& f) {
-  using FuncReturn = decltype(std::move(f)(rvalue));
-  using Errorator = typename FuncReturn::errorator_type;
-  using Futurator = typename Errorator::template futurize<FuncReturn>;
-  return typename Futurator::type {
-    seastar::do_with(std::move(rvalue),
-      [f = std::move(f)] (T& moved_rvalue) mutable {
-        return Errorator::plainify(std::move(f)(moved_rvalue));
-      })
-  };
-}
-
 // define the interface between error types and errorator
 template <class ConcreteErrorT>
 class error_t {
@@ -368,6 +355,10 @@ private:
 
   public:
     using errorator_type = ::crimson::errorator<AllowedErrors...>;
+    using promise_type = seastar::promise<ValuesT...>;
+
+    using base_t::available;
+    using base_t::failed;
 
     [[gnu::always_inline]]
     _future(base_t&& base)
@@ -543,11 +534,6 @@ private:
                                               Iterator end,
                                               AsyncAction action);
 
-    // for the sake of `plainify()` let any errorator convert errorated
-    // future into plain one.
-    template <class...>
-    friend class errorator;
-
     template <class...>
     friend class ::seastar::future;
   };
@@ -632,15 +618,6 @@ public:
   };
 
 private:
-  template <class... Args>
-  static decltype(auto) plainify(seastar::future<Args...>&& fut) {
-    return std::forward<seastar::future<Args...>>(fut);
-  }
-  template <class Arg>
-  static decltype(auto) plainify(Arg&& arg) {
-    return std::forward<typename Arg::base_t>(arg);
-  }
-
   template <class T, class = std::void_t<T>>
   class futurize {
     using vanilla_futurize = seastar::futurize<T>;
@@ -706,9 +683,6 @@ private:
   // we were exploiting before.
   template <class...>
   friend class errorator;
-
-  template<typename T, typename F>
-  friend inline auto do_with(T&&, F&&);
 }; // class errorator, generic template
 
 // no errors? errorator<>::future is plain seastar::future then!
@@ -825,4 +799,12 @@ struct futurize<Container<::crimson::errorated_future_marker<Values...>>> {
   }
 };
 
+namespace internal {
+template <template <class...> class Container,
+          class... Values>
+struct continuation_base_from_future<Container<::crimson::errorated_future_marker<Values...>>> {
+  using type = continuation_base<Values...>;
+};
+}
+
 } // namespace seastar
index a614d61fcb6dcab85a0934b81657db6814a53647..b14bb103c594eacc859ca961d940e3ca63ae081d 100644 (file)
@@ -438,8 +438,8 @@ seastar::future<Ref<MOSDOpReply>> PG::do_osd_ops(Ref<MOSDOp> m)
   const auto oid = m->get_snapid() == CEPH_SNAPDIR ? m->get_hobj().get_head()
                                                    : m->get_hobj();
   return backend->get_object_state(oid).safe_then([this, m](auto os) mutable {
-    return crimson::do_with(OpsExecuter{std::move(os), *this/* as const& */, m},
-                            [this, m] (auto& ox) {
+    return seastar::do_with(OpsExecuter{std::move(os), *this/* as const& */, m},
+                         [this, m] (auto& ox) {
       return crimson::do_for_each(m->ops, [this, &ox](OSDOp& osd_op) {
         logger().debug("will be handling op {}", ceph_osd_op_name(osd_op.op.op));
         return ox.execute_osd_op(osd_op);