 |
OpendTect
6.6
|
Go to the documentation of this file.
67 int queueid=cDefaultQueueID(),
68 bool putfirstinline=
false,
69 bool discardduplicates=
false,
70 bool forcedifferentthread=
false);
77 bool firstinline =
false);
83 bool firstinline =
false );
132 friend class WorkThread;
199 inline bool isOK()
const;
200 inline bool execute();
214 friend class WorkThread;
218 #define mSTFN(clss,fn) ((::TaskFunction)(&clss::fn))
219 #define mWMT(obj,clss,fn) ::Threads::Work( obj, mSTFN(clss,fn) )
225 : obj_( 0 ), cbf_( 0 ), tf_( 0 ), stf_( 0 ) {}
230 , cbf_( cb.cbFn() ), tf_( 0 ), stf_( 0 ) {}
234 : obj_( o ), cbf_( 0 ), tf_( f ), stf_( 0 ), takeover_( false ) {}
238 : obj_( 0 ), cbf_( 0 ), tf_( 0 ), stf_( f ) {}
242 : obj_( &t ), cbf_( 0 ), tf_(
mSTFN(
Task,execute) ), stf_( 0 )
243 , takeover_( takeover ) {}
247 {
return stf_ || (obj_ && (tf_ || cbf_) ); }
252 if ( stf_ )
return stf_();
255 const bool res = (obj_->*tf_)();
264 if ( takeover_ )
delete obj_;
void addWork(const Work &, CallBack *finished=0, int queueid=cDefaultQueueID(), bool putfirstinline=false, bool discardduplicates=false, bool forcedifferentthread=false)
CallBacker * obj_
Definition: threadwork.h:206
BufferStringSet queuenames_
Definition: threadwork.h:147
ObjectSet< WorkThread > freethreads_
Definition: threadwork.h:141
bool addWork(TypeSet< Work > &, int queueid=-1, bool firstinline=false)
TaskFunction tf_
Definition: threadwork.h:208
const Work * getWork(CallBacker *) const
static Threads::WorkManager & twm()
ObjectSet< WorkThread > threads_
Definition: threadwork.h:139
Set of BufferString objects.
Definition: bufstringset.h:26
ConditionVar & workloadcond_
Definition: threadwork.h:150
void reduceWorkload(int queueidx)
#define mExpClass(module)
Definition: commondefs.h:177
void removeQueue(int queueid, bool finishall)
bool execute()
Definition: threadwork.h:250
void(CallBacker::*)(CallBacker *) CallBackFunction
Definition: callback.h:38
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:148
TypeSet< QueueType > queuetypes_
Definition: threadwork.h:146
static int cDefaultQueueID()
Definition: threadwork.h:61
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
int freeid_
Definition: threadwork.h:152
int reportFinishedAndAskForMore(WorkThread *, int oldqueueid)
int nrFreeThreads() const
Valid right now, may change any time.
bool isOK() const
Definition: threadwork.h:246
#define mODTextTranslationClass(clss)
Definition: uistring.h:40
void emptyQueue(int queueid, bool finishall)
Work()
Definition: threadwork.h:224
StaticTaskFunction stf_
Definition: threadwork.h:209
TypeSet< int > queueworkload_
Definition: threadwork.h:145
Notifier< WorkManager > isidle
Definition: threadwork.h:118
TypeSet< CallBack > callbacks_
Definition: threadwork.h:137
TypeSet< Work > workload_
Definition: threadwork.h:135
CallBacks object-oriented (object + method).
Definition: callback.h:62
@ SingleThread
Definition: threadwork.h:48
bool takeover_
Definition: threadwork.h:210
bool isWorkThread() const
Generalization of something (e.g. a computation) that needs to be done in multiple steps.
Definition: task.h:28
Takes work and puts it on a queue for execution either in parallel, singlethread or manual.
Definition: threadwork.h:41
int queueSize(int queueid) const
Is an object that faciliates many threads to wait for something to happen.
Definition: thread.h:110
uiString uiMessage(CallBacker *) const
Class to help setup a callback handling.
Definition: notify.h:126
bool getWorkExitStatus(CallBacker *) const
TypeSet< int > queueids_
Definition: threadwork.h:144
TypeSet< int > workqueueid_
Definition: threadwork.h:136
int queueSizeNoLock(int queueid) const
bool removeWork(const Work &)
bool executeQueue(int queueid)
int nrThreads() const
Definition: threadwork.h:113
bool(* StaticTaskFunction)()
Definition: threadwork.h:24
Notifier< WorkManager > isShuttingDown
Definition: threadwork.h:122
bool(CallBacker::* TaskFunction)()
Definition: threadwork.h:25
uiString errMsg() const
Definition: threadwork.h:201
String that is able to hold international (UTF-8) strings for the user interface.
Definition: uistring.h:121
static const uiString & emptyString()
Definition: uistring.h:300
CallBackFunction cbf_
Definition: threadwork.h:207
bool operator==(const Work &) const
void setQueueName(int queueid, const char *)
uiString msg_
Definition: threadwork.h:212
WorkManager(int nrthreads=-1)
bool executeWork(Work *, int sz, int queueid=-1, bool firstinline=false)
Returns when finished with all.
ObjectSet< const void > threadids_
Definition: threadwork.h:140
BoolTypeSet queueisclosing_
Definition: threadwork.h:148
The abstraction of something that can be done. It can be an ordinary CallBack, a static function (mus...
Definition: threadwork.h:189
interface to threads that should be portable.
Definition: atomic.h:23
QueueType
Definition: threadwork.h:48
const int twmid_
Only for debugging.
Definition: threadwork.h:153
int addQueue(QueueType type, const char *name)
#define mSTFN(clss, fn)
Definition: threadwork.h:218
Sets of (small) copyable elements.
Definition: commontypes.h:29
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021