mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Add a way to early abort a task from a Job, apply that to the highlight effect to shave unecessary work
This commit is contained in:
parent
246ac25d0a
commit
b21b98c810
3 changed files with 23 additions and 13 deletions
|
@ -455,7 +455,7 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
|
|||
}
|
||||
|
||||
if (numLayers == 0) {
|
||||
renderContext->abortTask();
|
||||
renderContext->taskFlow.abortTask();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ JobContext::JobContext(const QLoggingCategory& category) :
|
|||
JobContext::~JobContext() {
|
||||
}
|
||||
|
||||
void JobContext::resetTaskFlow() {
|
||||
void TaskFlow::reset() {
|
||||
_doAbortTask = false;
|
||||
}
|
||||
|
||||
void JobContext::abortTask() {
|
||||
void TaskFlow::abortTask() {
|
||||
_doAbortTask = true;
|
||||
}
|
||||
|
||||
bool JobContext::doAbortTask() const {
|
||||
bool TaskFlow::doAbortTask() const {
|
||||
return _doAbortTask;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,21 @@ template <class JC> class JobT;
|
|||
template <class JC> class TaskT;
|
||||
class JobNoIO {};
|
||||
|
||||
class TaskFlow {
|
||||
public:
|
||||
TaskFlow() = default;
|
||||
~TaskFlow() = default;
|
||||
|
||||
// called after each job
|
||||
void reset();
|
||||
|
||||
void abortTask();
|
||||
bool doAbortTask() const;
|
||||
|
||||
protected:
|
||||
bool _doAbortTask{ false };
|
||||
};
|
||||
|
||||
class JobContext {
|
||||
public:
|
||||
JobContext(const QLoggingCategory& category);
|
||||
|
@ -35,15 +50,10 @@ public:
|
|||
std::shared_ptr<JobConfig> jobConfig { nullptr };
|
||||
const QLoggingCategory& profileCategory;
|
||||
|
||||
// control flow commands
|
||||
void resetTaskFlow();
|
||||
void abortTask();
|
||||
|
||||
// Check command flow
|
||||
bool doAbortTask() const;
|
||||
// Task flow control
|
||||
TaskFlow taskFlow{};
|
||||
|
||||
protected:
|
||||
bool _doAbortTask{ false };
|
||||
};
|
||||
using JobContextPointer = std::shared_ptr<JobContext>;
|
||||
|
||||
|
@ -316,8 +326,8 @@ public:
|
|||
if (config->alwaysEnabled || config->enabled) {
|
||||
for (auto job : TaskConcept::_jobs) {
|
||||
job.run(jobContext);
|
||||
if (jobContext->doAbortTask()) {
|
||||
jobContext->resetTaskFlow();
|
||||
if (jobContext->taskFlow.doAbortTask()) {
|
||||
jobContext->taskFlow.reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue