![]() |
OpendTect-6_4
6.4
|
Takes work and puts it on a queue for execution either in parallel, singlethread or manual. More...
Public Types | |
| enum | QueueType { MultiThread, SingleThread, Manual } |
Public Member Functions | |
| WorkManager (int nrthreads=-1) | |
| ~WorkManager () | |
| int | addQueue (QueueType type, const char *name) |
| void | setQueueName (int queueid, const char *) |
| int | queueSize (int queueid) const |
| void | emptyQueue (int queueid, bool finishall) |
| void | removeQueue (int queueid, bool finishall) |
| bool | executeQueue (int queueid) |
| void | addWork (const Work &, CallBack *finished=0, int queueid=cDefaultQueueID(), bool putfirstinline=false, bool discardduplicates=false, bool forcedifferentthread=false) |
| bool | addWork (TypeSet< Work > &, int queueid=-1, bool firstinline=false) |
| bool | executeWork (Work *, int sz, int queueid=-1, bool firstinline=false) |
| Returns when finished with all. More... | |
| bool | removeWork (const Work &) |
| const Work * | getWork (CallBacker *) const |
| bool | getWorkExitStatus (CallBacker *) const |
| int | nrThreads () const |
| int | nrFreeThreads () const |
| Valid right now, may change any time. More... | |
| bool | isWorkThread () const |
| void | shutdown () |
| void | setQuickStop (bool yn) |
| Only for MMP batchprogs. More... | |
Public Member Functions inherited from CallBacker | |
| CallBacker () | |
| CallBacker (const CallBacker &) | |
| virtual | ~CallBacker () |
| bool | attachCB (NotifierAccess &, const CallBack &, bool onlyifnew=false) |
| bool | attachCB (NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) |
| void | detachCB (NotifierAccess &, const CallBack &) |
| void | detachCB (NotifierAccess *notif, const CallBack &cb) |
| bool | isNotifierAttached (NotifierAccess *) const |
| Only for debugging purposes, don't use. More... | |
Static Public Member Functions | |
| static int | cDefaultQueueID () |
| static Threads::WorkManager & | twm () |
Public Attributes | |
| Notifier< WorkManager > | isidle |
| Notifier< WorkManager > | isShuttingDown |
Protected Member Functions | |
| int | queueSizeNoLock (int queueid) const |
| int | reportFinishedAndAskForMore (WorkThread *, int oldqueueid) |
| void | reduceWorkload (int queueidx) |
Protected Member Functions inherited from CallBacker | |
| void | detachAllNotifiers () |
| Call from the destructor of your inherited object. More... | |
Protected Attributes | |
| TypeSet< Work > | workload_ |
| TypeSet< int > | workqueueid_ |
| TypeSet< CallBack > | callbacks_ |
| ObjectSet< WorkThread > | threads_ |
| ObjectSet< const void > | threadids_ |
| ObjectSet< WorkThread > | freethreads_ |
| TypeSet< int > | queueids_ |
| TypeSet< int > | queueworkload_ |
| TypeSet< QueueType > | queuetypes_ |
| BufferStringSet | queuenames_ |
| BoolTypeSet | queueisclosing_ |
| ConditionVar & | workloadcond_ |
| int | freeid_ |
| const int | twmid_ |
| Only for debugging. More... | |
| bool | quickstop_ |
Friends | |
| class | WorkThread |
Takes work and puts it on a queue for execution either in parallel, singlethread or manual.
| Threads::WorkManager::WorkManager | ( | int | nrthreads = -1 | ) |
| Threads::WorkManager::~WorkManager | ( | ) |
| int Threads::WorkManager::addQueue | ( | QueueType | type, |
| const char * | name | ||
| ) |
Manual queues will not be executed automaticall, only at executeQueue.
| name | is for debugging |
| void Threads::WorkManager::addWork | ( | const Work & | , |
| CallBack * | finished = 0, |
||
| int | queueid = cDefaultQueueID(), |
||
| bool | putfirstinline = false, |
||
| bool | discardduplicates = false, |
||
| bool | forcedifferentthread = false |
||
| ) |
| forcedifferentthread | will force work to be put on the queue, even if it could be done directly in current thread. |
| bool Threads::WorkManager::addWork | ( | TypeSet< Work > & | , |
| int | queueid = -1, |
||
| bool | firstinline = false |
||
| ) |
|
inlinestatic |
| void Threads::WorkManager::emptyQueue | ( | int | queueid, |
| bool | finishall | ||
| ) |
| bool Threads::WorkManager::executeQueue | ( | int | queueid | ) |
Runs all jobs in a que. Only for manual queues
| bool Threads::WorkManager::executeWork | ( | Work * | , |
| int | sz, | ||
| int | queueid = -1, |
||
| bool | firstinline = false |
||
| ) |
Returns when finished with all.
| const Work* Threads::WorkManager::getWork | ( | CallBacker * | ) | const |
When a work is sumbmitted with a callback, the callback is called with a callbacker. If called from the callback and the callbacker is non-zero, a pointer to the work that was completed is returned. If not possible, a zero pointer will be returned.
| bool Threads::WorkManager::getWorkExitStatus | ( | CallBacker * | ) | const |
When a work is sumbmitted with a callback, the callback is called with a callbacker. If called from the callback and the callbacker is non-zero, the exit status of the work will be returned. Otherwise false.
| bool Threads::WorkManager::isWorkThread | ( | ) | const |
| int Threads::WorkManager::nrFreeThreads | ( | ) | const |
Valid right now, may change any time.
|
inline |
| int Threads::WorkManager::queueSize | ( | int | queueid | ) | const |
|
protected |
|
inlineprotected |
| void Threads::WorkManager::removeQueue | ( | int | queueid, |
| bool | finishall | ||
| ) |
Removes queue. If finishall is true, all work in the queue will be finished.
| bool Threads::WorkManager::removeWork | ( | const Work & | ) |
Removes the task from queue and stop it if allready running.
|
protected |
| void Threads::WorkManager::setQueueName | ( | int | queueid, |
| const char * | |||
| ) |
|
inline |
Only for MMP batchprogs.
| void Threads::WorkManager::shutdown | ( | ) |
|
static |
|
friend |
|
protected |
|
protected |
| Notifier<WorkManager> Threads::WorkManager::isidle |
| Notifier<WorkManager> Threads::WorkManager::isShuttingDown |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Only for debugging.
|
protected |
|
protected |
Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019