// 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;
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);
};
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);