diff --git a/aether/actions/actions_queue.h b/aether/actions/actions_queue.h index 12f6e720..903270b7 100644 --- a/aether/actions/actions_queue.h +++ b/aether/actions/actions_queue.h @@ -37,18 +37,13 @@ class ActionsQueue final : public Action { on_finished); // subscribe to the action finished }; - using Factory = std::function()>; + using Factory = std::function()>; - template - explicit StageFactory(TStageRunner runner) - : factory_([runner{std::move(runner)}]() mutable { - runner.Run(); - auto action = runner.action(); - - using ActionType = std::decay_t; - static VTable vtable = [&]() { - VTable vt; - vt.stop = [](void* obj) { + template + static VTable const* MakeVTable() { + static constexpr VTable vtable{ + .stop = + [](void* obj) { if (obj == nullptr) { return; } @@ -56,22 +51,33 @@ class ActionsQueue final : public Action { auto* a = static_cast(obj); a->Stop(); } - }; - vt.finished_event = - [](void* obj, - SmallFunction on_finished) - -> Subscription { - if (obj == nullptr) { - return Subscription{}; - } - auto* a = static_cast(obj); - return a->FinishedEvent().Subscribe( - [on_finished{std::move(on_finished)}]() { on_finished(); }); - }; - return vt; - }(); - - return std::make_pair(&vtable, action ? &*action : nullptr); + }, + .finished_event = + [](void* obj, + [[maybe_unused]] SmallFunction + on_finished) -> Subscription { + if (obj == nullptr) { + return Subscription{}; + } + + auto* a = static_cast(obj); // 70 + + return a->FinishedEvent().Subscribe( // 72 + [on_finished{std::move(on_finished)}]() { on_finished(); }); + }, + }; + return &vtable; + } + + template + explicit StageFactory(TStageRunner runner) + : factory_([runner{std::move(runner)}]() mutable { + runner.Run(); + auto action = runner.action(); + using TypeOfAction = std::decay_t; + + return std::make_pair(MakeVTable(), + action ? &*action : nullptr); }) {} template @@ -90,7 +96,7 @@ class ActionsQueue final : public Action { private: Factory factory_; - VTable* vtable_{}; + VTable const* vtable_{}; void* action_obj_{}; };