Skip to content

Commit

Permalink
scheduler: avoid handling ::next in the update function
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Nov 14, 2023
1 parent a5608bf commit 9bad120
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/entt/process/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ struct process_handler {
process->tick(delta, data);

if(process->rejected()) {
handler.next.reset();
return true;
} else if(process->finished()) {
if(handler.next) {
handler = std::move(*handler.next);
// forces the process to exit the uninitialized state
return handler.update(handler, {}, nullptr);
}

return true;
}

Expand Down Expand Up @@ -267,9 +262,15 @@ class basic_scheduler {
for(auto pos = handlers.size(); pos; --pos) {
auto &curr = handlers[pos - 1u];

if(const auto dead = curr.update(curr, delta, data); dead) {
std::swap(curr, handlers.back());
handlers.pop_back();
if(auto dead = curr.update(curr, delta, data); dead) {
if(curr.next) {
curr = std::move(*curr.next);
// forces the process to exit the uninitialized state
curr.update(curr, {}, nullptr);
} else {
std::swap(curr, handlers.back());
handlers.pop_back();
}
}
}
}
Expand Down

0 comments on commit 9bad120

Please sign in to comment.