12 #ifndef CXTHREADEDTIMEDALGORITHM_H_ 13 #define CXTHREADEDTIMEDALGORITHM_H_ 15 #include "cxResourceExport.h" 17 #include <QFutureWatcher> 18 #include <QtConcurrent/QtConcurrentRun> 43 connect(&mWatcher, SIGNAL(finished()),
this, SLOT(finishedSlot()));
44 connect(&mWatcher, SIGNAL(finished()),
this, SLOT(postProcessingSlot()));
45 connect(&mWatcher, SIGNAL(finished()),
this, SIGNAL(finished()));
52 this->preProcessingSlot();
55 virtual bool isFinished()
const {
return mWatcher.isFinished(); }
56 virtual bool isRunning()
const {
return mWatcher.isRunning(); }
61 virtual void postProcessingSlot() = 0;
64 virtual T calculate() = 0;
72 mWatcher.setFuture(mFutureResult);
76 T result = mWatcher.future().result();
86 QFuture<T> mFutureResult;
87 QFutureWatcher<T> mWatcher;
110 virtual void postProcessingSlot();
113 virtual QString calculate();
ThreadedTimedAlgorithm(QString product, int secondsBetweenAnnounce)
Base class for algorithms that wants to time their execution.
Base class for algorithms that wants to thread and time their execution. T is the return type of the ...
virtual void preProcessingSlot()
This happens before the thread (calculate) is started, here non-thread safe functions can be called...
Implementation of ThreadedTimedAlgorithm that shows the minimum implementation of this class...
virtual ~ThreadedTimedAlgorithm()
virtual bool isFinished() const
virtual bool isRunning() const
Namespace for all CustusX production code.