OpendTect
6.6
|
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 | 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) |
void | emptyQueue (int queueid, bool finishall) |
bool | executeQueue (int queueid) |
bool | executeWork (Work *, int sz, int queueid=-1, bool firstinline=false) |
Returns when finished with all. More... | |
const Work * | getWork (CallBacker *) const |
bool | getWorkExitStatus (CallBacker *) const |
bool | isWorkThread () const |
int | nrFreeThreads () const |
Valid right now, may change any time. More... | |
int | nrThreads () const |
int | queueSize (int queueid) const |
void | removeQueue (int queueid, bool finishall) |
bool | removeWork (const Work &) |
void | setQueueName (int queueid, const char *) |
void | shutdown () |
uiString | uiMessage (CallBacker *) const |
Public Member Functions inherited from CallBacker | |
CallBacker () | |
CallBacker (const CallBacker &) | |
virtual | ~CallBacker () |
bool | attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const |
bool | attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const |
void | detachAllNotifiers () const |
Call from the destructor of your inherited object. More... | |
void | detachCB (const NotifierAccess &, const CallBack &) const |
void | detachCB (const NotifierAccess *notif, const CallBack &cb) const |
virtual bool | isCapsule () const |
bool | isNotifierAttached (const NotifierAccess *) const |
Only for debugging purposes, don't use. More... | |
void | stopReceivingNotifications () const |
Static Public Member Functions | |
static int | cDefaultQueueID () |
static Threads::WorkManager & | twm () |
Static Public Member Functions inherited from CallBacker | |
static void | createReceiverForCurrentThread () |
static void | removeReceiverForCurrentThread () |
Public Attributes | |
Notifier< WorkManager > | isidle |
Notifier< WorkManager > | isShuttingDown |
Protected Member Functions | |
int | queueSizeNoLock (int queueid) const |
void | reduceWorkload (int queueidx) |
int | reportFinishedAndAskForMore (WorkThread *, int oldqueueid) |
Protected Attributes | |
TypeSet< CallBack > | callbacks_ |
int | freeid_ |
ObjectSet< WorkThread > | freethreads_ |
TypeSet< int > | queueids_ |
BoolTypeSet | queueisclosing_ |
BufferStringSet | queuenames_ |
TypeSet< QueueType > | queuetypes_ |
TypeSet< int > | queueworkload_ |
ObjectSet< const void > | threadids_ |
ObjectSet< WorkThread > | threads_ |
const int | twmid_ |
Only for debugging. More... | |
TypeSet< Work > | workload_ |
ConditionVar & | workloadcond_ |
TypeSet< int > | workqueueid_ |
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.
type | See QueueType |
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. |
finished,queueid,putfirstinline,discardduplicates |
bool Threads::WorkManager::addWork | ( | TypeSet< Work > & | , |
int | queueid = -1 , |
||
bool | firstinline = false |
||
) |
Will wait for all work to be finished.
|
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 submitted 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 submitted 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 * | |||
) |
void Threads::WorkManager::shutdown | ( | ) |
|
static |
uiString Threads::WorkManager::uiMessage | ( | CallBacker * | ) | const |
When a work is submitted and setup with a task, returns the task message when not finished successfully.
|
friend |
|
protected |
|
protected |
Notifier<WorkManager> Threads::WorkManager::isidle |
Notifier<WorkManager> Threads::WorkManager::isShuttingDown |
|
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. 1995-2022