digiKam
Digikam::DynamicThread Class Referenceabstract
+ Inheritance diagram for Digikam::DynamicThread:

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
 

Member Enumeration Documentation

◆ State

Enumerator
Inactive 
Scheduled 
Running 
Deactivating 

Constructor & Destructor Documentation

◆ DynamicThread()

Digikam::DynamicThread::DynamicThread ( QObject *const  parent = nullptr)
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().

◆ ~DynamicThread()

Digikam::DynamicThread::~DynamicThread ( )
override

The destructor calls stop() and wait(), but if you, in your destructor, delete any data that is accessed by your run() method, you must call stop() and wait() before yourself.

References shutDown().

Member Function Documentation

◆ finished

◆ isFinished()

bool Digikam::DynamicThread::isFinished ( ) const

References Inactive.

◆ isRunning()

bool Digikam::DynamicThread::isRunning ( ) const

◆ priority()

QThread::Priority Digikam::DynamicThread::priority ( ) const

Referenced by setPriority().

◆ run()

virtual void Digikam::DynamicThread::run ( )
pure virtual

Implement this pure virtual function in your subclass.

Implemented in Digikam::ScanStateFilter, Digikam::LoadSaveThread, Digikam::ImageHistogram, and Digikam::DImgThreadedFilter.

◆ runningFlag()

bool Digikam::DynamicThread::runningFlag ( ) const volatile
protected

◆ setEmitSignals()

void Digikam::DynamicThread::setEmitSignals ( bool  emitThem)

◆ setPriority()

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().

◆ shutDown()

void Digikam::DynamicThread::shutDown ( )
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().

◆ start [1/2]

◆ start() [2/2]

void Digikam::DynamicThread::start ( QMutexLocker &  locker)
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().

◆ starting

void Digikam::DynamicThread::starting ( )
signal

Emitted if emitSignals is enabled

◆ state()

◆ stop [1/2]

◆ stop() [2/2]

void Digikam::DynamicThread::stop ( QMutexLocker &  locker)
protected

◆ threadMutex()

◆ wait [1/2]

◆ wait() [2/2]

void Digikam::DynamicThread::wait ( QMutexLocker &  locker)
protected

Friends And Related Function Documentation

◆ DynamicThreadPriv

friend class DynamicThreadPriv
friend

The documentation for this class was generated from the following files: