48 int addQueue(
QueueType type,
const char* name);
54 void setQueueName(
int queueid,
const char*);
55 int queueSize(
int queueid)
const;
56 void emptyQueue(
int queueid,
bool finishall);
57 void removeQueue(
int queueid,
bool finishall);
61 bool executeQueue(
int queueid);
66 int queueid=cDefaultQueueID(),
67 bool putfirstinline=
false,
68 bool discardduplicates=
false,
69 bool forcedifferentthread=
false);
76 bool firstinline =
false);
78 bool executeWork(
Work*,
int sz,
int queueid = -1,
79 bool firstinline =
false );
81 bool removeWork(
const Work&);
87 const Work* getWork(CallBacker*)
const;
95 bool getWorkExitStatus(CallBacker*)
const;
105 int nrFreeThreads()
const;
107 bool isWorkThread()
const;
120 int queueSizeNoLock(
int queueid)
const;
121 int reportFinishedAndAskForMore(WorkThread*,
123 inline void reduceWorkload(
int queueidx);
125 friend class WorkThread;
189 inline Work(
Task& t,
bool takeover);
192 inline bool isOK()
const;
197 friend class WorkThread;
207 #define mSTFN(clss,fn) ((::TaskFunction)(&clss::fn)) 208 #define mWMT(obj,clss,fn) ::Threads::Work( obj, mSTFN(clss,fn) ) 214 : obj_( 0 ), cbf_( 0 ), tf_( 0 ), stf_( 0 ) {}
244 const bool res = (
obj_->*
tf_)();
#define mExpClass(module)
Definition: commondefs.h:160
Is an object that faciliates many threads to wait for something to happen.
Definition: thread.h:108
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
TypeSet< int > workqueueid_
Definition: threadwork.h:129
void setQuickStop(bool yn)
Only for MMP batchprogs.
Definition: threadwork.h:115
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
Notifier< WorkManager > isShuttingDown
Definition: threadwork.h:113
TypeSet< int > queueids_
Definition: threadwork.h:137
CallBacker * obj_
Definition: threadwork.h:200
bool isOK() const
Definition: threadwork.h:235
void(CallBacker::* CallBackFunction)(CallBacker *)
Definition: callback.h:38
bool(* StaticTaskFunction)()
Definition: threadwork.h:23
Set of BufferString objects.
Definition: bufstringset.h:28
#define mSTFN(clss, fn)
Definition: threadwork.h:207
int nrThreads() const
Definition: threadwork.h:104
CallBackFunction cbf_
Definition: threadwork.h:201
Takes work and puts it on a queue for execution either in parallel, singlethread or manual...
Definition: threadwork.h:39
Work()
Definition: threadwork.h:213
Definition: threadwork.h:47
Definition: callback.h:254
bool(CallBacker::* TaskFunction)()
Definition: threadwork.h:24
interface to threads that should be portable.
Definition: atomic.h:28
ObjectSet< const void > threadids_
Definition: threadwork.h:133
Set of (small) copyable elements.
Definition: commontypes.h:30
BoolTypeSet queueisclosing_
Definition: threadwork.h:141
const int twmid_
Only for debugging.
Definition: threadwork.h:146
QueueType
Definition: threadwork.h:47
bool takeover_
Definition: threadwork.h:204
TaskFunction tf_
Definition: threadwork.h:202
BufferStringSet queuenames_
Definition: threadwork.h:140
ObjectSet< WorkThread > threads_
Definition: threadwork.h:132
ObjectSet< WorkThread > freethreads_
Definition: threadwork.h:134
ConditionVar & workloadcond_
Definition: threadwork.h:143
TypeSet< QueueType > queuetypes_
Definition: threadwork.h:139
bool doRun()
Definition: threadwork.h:239
static int cDefaultQueueID()
Definition: threadwork.h:60
bool quickstop_
Definition: threadwork.h:147
int freeid_
Definition: threadwork.h:145
Notifier< WorkManager > isidle
Definition: threadwork.h:109
CallBacks object-oriented (object + method).
Definition: callback.h:57
StaticTaskFunction stf_
Definition: threadwork.h:203
Generalization of something (e.g. a computation) that needs to be done in multiple steps...
Definition: task.h:28
TypeSet< int > queueworkload_
Definition: threadwork.h:138
TypeSet< CallBack > callbacks_
Definition: threadwork.h:130
TypeSet< Work > workload_
Definition: threadwork.h:128
The abstraction of something that can be done. It can be an ordinary CallBack, a static function (mus...
Definition: threadwork.h:182