[nostalgia/studio] Add finished signal to Task

This commit is contained in:
Gary Talent 2022-03-19 19:32:30 -05:00
parent 2881a28dc8
commit 96ca0cb686
2 changed files with 7 additions and 2 deletions

View File

@ -10,7 +10,11 @@ namespace nostalgia::studio {
void TaskRunner::update(core::Context *ctx) noexcept {
oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](auto &t) {
return t->update(ctx) == TaskState::Done;
const auto done = t->update(ctx) == TaskState::Done;
if (done) {
t->finished.emit();
}
return done;
})));
}

View File

@ -17,6 +17,7 @@ enum class TaskState {
class Task: public ox::SignalHandler {
public:
ox::Signal<ox::Error()> finished;
~Task() noexcept override = default;
virtual TaskState update(nostalgia::core::Context *ctx) noexcept = 0;
};
@ -29,4 +30,4 @@ class TaskRunner {
void add(Task *task) noexcept;
};
}
}