digiKam
|
Public Types | |
enum | State { Inactive , Scheduled , Running , Deactivating } |
Public Slots | |
void | start () |
void | stop () |
void | wait () |
Signals | |
void | finished () |
void | starting () |
Public Member Functions | |
DynamicThread (QObject *const parent=nullptr) | |
bool | isFinished () const |
bool | isRunning () const |
QThread::Priority | priority () const |
virtual void | run ()=0 |
void | setEmitSignals (bool emitThem) |
void | setPriority (QThread::Priority priority) |
State | state () const |
~DynamicThread () override | |
Protected Member Functions | |
bool | runningFlag () const volatile |
void | shutDown () |
void | start (QMutexLocker &locker) |
void | stop (QMutexLocker &locker) |
QMutex * | threadMutex () const |
void | wait (QMutexLocker &locker) |
Friends | |
class | DynamicThreadPriv |
|
explicit |
This class extends QRunnable, so you have to reimplement virtual void run(). In all aspects the class will act similar to a QThread.
References Digikam::ThreadManager::initialize(), and Digikam::ThreadManager::instance().
|
override |
|
signal |
bool Digikam::DynamicThread::isFinished | ( | ) | const |
References Inactive.
bool Digikam::DynamicThread::isRunning | ( | ) | const |
References Deactivating, Running, and Scheduled.
Referenced by Digikam::DImgThreadedFilter::cancelFilter(), and Digikam::ImageHistogram::isCalculating().
QThread::Priority Digikam::DynamicThread::priority | ( | ) | const |
Referenced by setPriority().
|
pure virtual |
Implement this pure virtual function in your subclass.
Implemented in Digikam::ScanStateFilter, Digikam::LoadSaveThread, Digikam::ImageHistogram, and Digikam::DImgThreadedFilter.
|
protected |
In you run() method, you shall regularly check for runningFlag() and cleanup and return if false.
Referenced by Digikam::ImageHistogram::calculate(), Digikam::RawProcessingFilter::continueQuery(), Digikam::LoadSaveThread::run(), Digikam::ScanStateFilter::run(), and Digikam::NREstimate::startAnalyse().
void Digikam::DynamicThread::setEmitSignals | ( | bool | emitThem | ) |
void Digikam::DynamicThread::setPriority | ( | QThread::Priority | priority | ) |
Sets the priority for this dynamic thread. Can be set anytime. If the thread is currently not running, the priority will be set when it is run next time. When you set QThread::InheritPriority (default), the priority is not changed but inherited from the thread pool.
References priority().
Referenced by Digikam::FacePipeline::Private::applyPriority(), and Digikam::FacePipeline::Private::createThumbnailLoadThread().
|
protected |
If you are deleting data in your destructor which is accessed from the thread, do one of the following from your destructor to guarantee a safe shutdown: 1) Call this method 2) Call stop() and wait(), knowing that nothing will call start() anymore after this 3) Be sure the thread will never be running at destruction. Note: This irrevocably stops this object. Note: It is not sufficient that your parent class does this. Calling this method, or providing one of the above mentioned equivalent guarantees, must be done by every single last class in the hierarchy with an implemented destructor deleting data. (the base class destructor is always called after the derived class)
References stop(), and wait().
Referenced by Digikam::ManagedLoadSaveThread::shutDown(), ~DynamicThread(), and Digikam::LoadSaveThread::~LoadSaveThread().
|
slot |
Referenced by Digikam::ImageHistogram::calculateInThread(), Digikam::FacePreviewLoader::checkRestart(), Digikam::ImageHistogram::getCount(), Digikam::ImageHistogram::getMaximum(), Digikam::ImageHistogram::getMean(), Digikam::ImageHistogram::getMedian(), Digikam::ImageHistogram::getStdDev(), Digikam::LoadSaveThread::load(), Digikam::ManagedLoadSaveThread::load(), Digikam::ManagedLoadSaveThread::loadThumbnail(), Digikam::DImgThreadedFilter::multithreadedSteps(), Digikam::ManagedLoadSaveThread::preloadThumbnail(), Digikam::ManagedLoadSaveThread::preloadThumbnailGroup(), Digikam::ManagedLoadSaveThread::prependThumbnailGroup(), Digikam::ScanStateFilter::process(), Digikam::LoadSaveThread::save(), Digikam::ManagedLoadSaveThread::save(), and Digikam::DImgThreadedFilter::startFilter().
|
protected |
Doing the same as start(), stop() and wait above, provide it with a locked QMutexLocker on mutex(). Note the start() will unlock and relock for scheduling once, after state change.
References Digikam::ThreadManager::instance(), and Digikam::ThreadManager::schedule().
|
signal |
Emitted if emitSignals is enabled
DynamicThread::State Digikam::DynamicThread::state | ( | ) | const |
|
slot |
Stop computation, sets the running flag to false.
Referenced by Digikam::WBFilter::autoExposureAdjustement(), Digikam::DImgThreadedFilter::cancelFilter(), Digikam::DImgThreadedFilter::multithreadedSteps(), Digikam::LoadSaveThread::run(), Digikam::ScanStateFilter::run(), shutDown(), Digikam::FacePreviewLoader::slotImageLoaded(), Digikam::FacePipeline::Private::stop(), and Digikam::ImageHistogram::stopCalculation().
|
protected |
|
protected |
This is the non-recursive mutex used to protect state variables and waiting in this class. You can use it if you want to protect your memory in the same scope as calling start, stop or wait, then using the QMutexLocker variants below. Note that when you have locked this mutex, you must use these variants, as the mutex is non-recursive.
Referenced by Digikam::ScanStateFilter::dispatch(), Digikam::LoadSaveThread::load(), Digikam::ManagedLoadSaveThread::load(), Digikam::ManagedLoadSaveThread::loadThumbnail(), Digikam::ManagedLoadSaveThread::preloadThumbnail(), Digikam::ManagedLoadSaveThread::preloadThumbnailGroup(), Digikam::ManagedLoadSaveThread::prependThumbnailGroup(), Digikam::ScanStateFilter::process(), Digikam::LoadSaveThread::run(), Digikam::ScanStateFilter::run(), Digikam::LoadSaveThread::save(), Digikam::ManagedLoadSaveThread::save(), Digikam::ManagedLoadSaveThread::shutDown(), Digikam::ManagedLoadSaveThread::stopAllTasks(), Digikam::ManagedLoadSaveThread::stopLoading(), Digikam::ManagedLoadSaveThread::stopSaving(), and Digikam::LoadSaveThread::taskHasFinished().
|
slot |
Waits until the thread finishes. Typically, call stop() before.
Referenced by Digikam::DImgThreadedFilter::cancelFilter(), Digikam::ThumbnailLoadThread::cleanUp(), shutDown(), Digikam::FacePreviewLoader::slotImageLoaded(), Digikam::ImageHistogram::stopCalculation(), and Digikam::FacePipeline::Private::wait().
|
protected |
|
friend |