]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: turn with_effect() into with_effect_on_obc().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 27 Nov 2019 15:08:41 +0000 (16:08 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 10 Feb 2020 13:52:20 +0000 (14:52 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/ops_executer.h

index 5641a211c89b63b7e077e0d6100e1faeea0353b7..fe4a56b5f994f41beea1ee1cdcac6152dcf88c39 100644 (file)
@@ -66,7 +66,8 @@ private:
   // the later on `submit_changes()` – after successfully processing main
   // stages of all involved operations. When any stage fails, none of all
   // scheduled effect-exposing stages will be executed.
-  // when operation requires this division, `with_effect()` should be used.
+  // when operation requires this division, some variant of `with_effect()`
+  // should be used.
   struct effect_t {
     virtual osd_op_errorator::future<> execute() = 0;
     virtual ~effect_t() = default;
@@ -87,7 +88,10 @@ private:
   seastar::chunked_fifo<std::unique_ptr<effect_t>> op_effects;
 
   template <class Context, class MainFunc, class EffectFunc>
-  auto with_effect(Context&& ctx, MainFunc&& main_func, EffectFunc&& effect_func);
+  auto with_effect_on_obc(
+    Context&& ctx,
+    MainFunc&& main_func,
+    EffectFunc&& effect_func);
 
   call_errorator::future<> do_op_call(class OSDOp& osd_op);
 
@@ -148,29 +152,35 @@ public:
 };
 
 template <class Context, class MainFunc, class EffectFunc>
-auto OpsExecuter::with_effect(
+auto OpsExecuter::with_effect_on_obc(
   Context&& ctx,
   MainFunc&& main_func,
   EffectFunc&& effect_func)
 {
   using context_t = std::decay_t<Context>;
   // the language offers implicit conversion to pointer-to-function for
-  // lambda only when it's closureless
-  static_assert(std::is_convertible_v<EffectFunc,
-                                      seastar::future<> (*)(context_t&&)>,
+  // lambda only when it's closureless. We enforce this restriction due
+  // the fact that `submit_changes()` std::moves many executer's parts.
+  using allowed_effect_func_t =
+    seastar::future<> (*)(context_t&&, ObjectContextRef);
+  static_assert(std::is_convertible_v<EffectFunc, allowed_effect_func_t>,
                 "with_effect function is not allowed to capture");
   struct task_t final : effect_t {
     context_t ctx;
     EffectFunc effect_func;
+    ObjectContextRef obc;
 
-    task_t(Context&& ctx, EffectFunc&& effect_func)
-       : ctx(std::move(ctx)), effect_func(std::move(effect_func)) {}
+    task_t(Context&& ctx, EffectFunc&& effect_func, ObjectContextRef obc)
+       : ctx(std::move(ctx)),
+         effect_func(std::move(effect_func)),
+         obc(std::move(obc)) {
+    }
     osd_op_errorator::future<> execute() final {
-      return std::move(effect_func)(std::move(ctx));
+      return std::move(effect_func)(std::move(ctx), std::move(obc));
     }
   };
   auto task =
-    std::make_unique<task_t>(std::move(ctx), std::move(effect_func));
+    std::make_unique<task_t>(std::move(ctx), std::move(effect_func), obc);
   auto& ctx_ref = task->ctx;
   op_effects.emplace_back(std::move(task));
   return std::forward<MainFunc>(main_func)(ctx_ref);