mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:23:33 +02:00
Introducing a way to abort a task from one of its job, using it to skip highlight tasks if nothing to highlight
This commit is contained in:
parent
33690e09b7
commit
246ac25d0a
3 changed files with 55 additions and 4 deletions
|
@ -453,6 +453,10 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (numLayers == 0) {
|
||||||
|
renderContext->abortTask();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
|
|
35
libraries/task/src/task/Task.cpp
Normal file
35
libraries/task/src/task/Task.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
//
|
||||||
|
// Task.cpp
|
||||||
|
// task/src/task
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 2/14/2018.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#include "Task.h"
|
||||||
|
|
||||||
|
using namespace task;
|
||||||
|
|
||||||
|
JobContext::JobContext(const QLoggingCategory& category) :
|
||||||
|
profileCategory(category) {
|
||||||
|
assert(&category);
|
||||||
|
}
|
||||||
|
|
||||||
|
JobContext::~JobContext() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void JobContext::resetTaskFlow() {
|
||||||
|
_doAbortTask = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JobContext::abortTask() {
|
||||||
|
_doAbortTask = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JobContext::doAbortTask() const {
|
||||||
|
return _doAbortTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,21 @@ class JobNoIO {};
|
||||||
|
|
||||||
class JobContext {
|
class JobContext {
|
||||||
public:
|
public:
|
||||||
JobContext(const QLoggingCategory& category) : profileCategory(category) {
|
JobContext(const QLoggingCategory& category);
|
||||||
assert(&category);
|
virtual ~JobContext();
|
||||||
}
|
|
||||||
virtual ~JobContext() {}
|
|
||||||
|
|
||||||
std::shared_ptr<JobConfig> jobConfig { nullptr };
|
std::shared_ptr<JobConfig> jobConfig { nullptr };
|
||||||
const QLoggingCategory& profileCategory;
|
const QLoggingCategory& profileCategory;
|
||||||
|
|
||||||
|
// control flow commands
|
||||||
|
void resetTaskFlow();
|
||||||
|
void abortTask();
|
||||||
|
|
||||||
|
// Check command flow
|
||||||
|
bool doAbortTask() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool _doAbortTask{ false };
|
||||||
};
|
};
|
||||||
using JobContextPointer = std::shared_ptr<JobContext>;
|
using JobContextPointer = std::shared_ptr<JobContext>;
|
||||||
|
|
||||||
|
@ -308,6 +316,10 @@ public:
|
||||||
if (config->alwaysEnabled || config->enabled) {
|
if (config->alwaysEnabled || config->enabled) {
|
||||||
for (auto job : TaskConcept::_jobs) {
|
for (auto job : TaskConcept::_jobs) {
|
||||||
job.run(jobContext);
|
job.run(jobContext);
|
||||||
|
if (jobContext->doAbortTask()) {
|
||||||
|
jobContext->resetTaskFlow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue