diff --git a/core/ControllableTask.h b/core/ControllableTask.h deleted file mode 100644 index 8fe5738..0000000 --- a/core/ControllableTask.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CONTROLLABLETASK_H -#define CONTROLLABLETASK_H -/** From answer by Hatter - * - * https://stackoverflow.com/questions/5423058/qfuture-that-can-be-cancelled-and-report-progress - */ - -//#include "TaskControl.h" -class TaskControl; - -template -class ControllableTask -{ -public: - using Result = T; - virtual ~ControllableTask() {} - virtual Result run(TaskControl& control) = 0; -}; - -#endif // CONTROLLABLETASK_H diff --git a/core/RunControllableTask.h b/core/RunControllableTask.h deleted file mode 100644 index 270e095..0000000 --- a/core/RunControllableTask.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef RUNCONTROLLABLETASK_H -#define RUNCONTROLLABLETASK_H -/** From answer by Hatter - * - * https://stackoverflow.com/questions/5423058/qfuture-that-can-be-cancelled-and-report-progress - */ - -#include -#include -#include -#include "ControllableTask.h" -#include "TaskControl.h" - -template -class RunControllableTask : public QFutureInterface , public QRunnable -{ -public: - RunControllableTask(ControllableTask* tsk) : task(tsk) { } - virtual ~RunControllableTask() { delete task; } - - QFuture start() - { - this->setRunnable(this); - this->reportStarted(); - QFuture future = this->future(); - QThreadPool::globalInstance()->start(this, /*m_priority*/ 0); - return future; - } - - void run() - { - if (this->isCanceled()) { - this->reportFinished(); - return; - } - TaskControl control(this); - try { - result = this->task->run(control); - if (!this->isCanceled()) { - this->reportResult(result); - } - } catch (QException &e) { - QFutureInterfaceBase::reportException(e); - } catch (...) { - QUnhandledException ex; - QFutureInterfaceBase::reportException(ex); - } - - this->reportFinished(); - } - -private: - T result; - ControllableTask *task; -}; - -#endif // RUNCONTROLLABLETASK_H diff --git a/core/TaskControl.h b/core/TaskControl.h deleted file mode 100644 index 3120e51..0000000 --- a/core/TaskControl.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TASKCONTROL_H -#define TASKCONTROL_H -/** From answer by Hatter - * - * https://stackoverflow.com/questions/5423058/qfuture-that-can-be-cancelled-and-report-progress - */ - -#include - -class TaskControl { -public: - TaskControl(QFutureInterfaceBase *f) : fu(f) { } - bool shouldRun() const { return !fu->isCanceled(); } -private: - QFutureInterfaceBase *fu; -}; - -#endif // TASKCONTROL_H diff --git a/core/TaskExecutor.h b/core/TaskExecutor.h deleted file mode 100644 index 9a73b30..0000000 --- a/core/TaskExecutor.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TASKEXECUTOR_H -#define TASKEXECUTOR_H -/* From answer by Hatter - * - * https://stackoverflow.com/questions/5423058/qfuture-that-can-be-cancelled-and-report-progress - */ -#include "ControllableTask.h" -#include "RunControllableTask.h" -#include -/** - * @brief The TaskExecutor class - * - * The user should sublass ControllableTask, implement background routine which checks sometimes - * method shouldRun() of TaskControl instance passed to run(TaskControl&) and then use it like: - * - * QFututre futureValue = TaskExecutor::run(new SomeControllableTask(inputForThatTask)); - * - * Then she may cancel it by calling futureValue.cancel(), bearing in mind that cancellation is - * graceful and not immediate. - * - */ -class TaskExecutor { -public: - template - static QFuture run(ControllableTask* task) { - return (new RunControllableTask(task))->start(); - } -}; - - - -#endif // TASKEXECUTOR_H diff --git a/core/core.pro b/core/core.pro index ab3d990..139f81f 100644 --- a/core/core.pro +++ b/core/core.pro @@ -46,10 +46,6 @@ HEADERS += PasswordManager.h \ Expected.h \ ExplainTreeModelItem.h \ json/json.h \ - TaskControl.h \ - ControllableTask.h \ - RunControllableTask.h \ - TaskExecutor.h \ SqlParser.h \ SqlAstNode.h \ SqlAstSelectList.h \ diff --git a/pglab/DatabaseWindow.cpp b/pglab/DatabaseWindow.cpp index 10053e3..4514c7f 100644 --- a/pglab/DatabaseWindow.cpp +++ b/pglab/DatabaseWindow.cpp @@ -6,7 +6,6 @@ #include "catalog/PgDatabaseCatalog.h" #include "ConnectionController.h" #include "MasterController.h" -#include "TaskExecutor.h" #include #include #include diff --git a/pglab/DatabaseWindow.h b/pglab/DatabaseWindow.h index c1fa73f..3b66326 100644 --- a/pglab/DatabaseWindow.h +++ b/pglab/DatabaseWindow.h @@ -5,7 +5,6 @@ #include "CatalogInspector.h" #include "OpenDatabase.h" #include "Pgsql_Connection.h" -#include "ControllableTask.h" #include "IDatabaseWindow.h" #include #include