diff --git a/src/entt/process/scheduler.hpp b/src/entt/process/scheduler.hpp index b41965c98..d0b540181 100644 --- a/src/entt/process/scheduler.hpp +++ b/src/entt/process/scheduler.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -57,12 +58,16 @@ class scheduler final { struct continuation final { continuation(process_handler *handler) : handler{handler} - {} + { + assert(handler); + } template continuation then(Args &&... args) { static_assert(std::is_base_of_v, Proc>); - handler = scheduler::then(handler, std::forward(args)...); + auto proc = typename process_handler::instance_type{new Proc{std::forward(args)...}, &scheduler::deleter}; + handler->next.reset(new process_handler{std::move(proc), &scheduler::update, &scheduler::abort, nullptr}); + handler = handler->next.get(); return *this; } @@ -104,17 +109,6 @@ class scheduler final { delete static_cast(proc); } - template - static auto then(process_handler *handler, Args &&... args) { - if(handler) { - auto proc = typename process_handler::instance_type{new Proc{std::forward(args)...}, &scheduler::deleter}; - handler->next.reset(new process_handler{std::move(proc), &scheduler::update, &scheduler::abort, nullptr}); - handler = handler->next.get(); - } - - return handler; - } - public: /*! @brief Unsigned integer type. */ using size_type = typename std::vector::size_type; @@ -186,11 +180,9 @@ public: template auto attach(Args &&... args) { static_assert(std::is_base_of_v, Proc>); - auto proc = typename process_handler::instance_type{new Proc{std::forward(args)...}, &scheduler::deleter}; process_handler handler{std::move(proc), &scheduler::update, &scheduler::abort, nullptr}; handlers.push_back(std::move(handler)); - return continuation{&handlers.back()}; }