46 int addQueue(
QueueType type,
const char* name);
52 void setQueueName(
int queueid,
const char*);
53 int queueSize(
int queueid)
const;
54 void emptyQueue(
int queueid,
bool finishall);
55 void removeQueue(
int queueid,
bool finishall);
59 bool executeQueue(
int queueid);
64 int queueid=cDefaultQueueID(),
65 bool putfirstinline=
false,
66 bool discardduplicates=
false,
67 bool forcedifferentthread=
false);
74 bool firstinline =
false);
79 bool executeWork(
Work*,
int sz,
int queueid = -1,
80 bool firstinline =
false );
82 bool removeWork(
const Work&);
88 const Work* getWork(CallBacker*)
const;
96 bool getWorkExitStatus(CallBacker*)
const;
106 int nrFreeThreads()
const;
108 bool isWorkThread()
const;
119 int queueSizeNoLock(
int queueid)
const;
120 int reportFinishedAndAskForMore(WorkThread*,
122 inline void reduceWorkload(
int queueidx);
124 friend class WorkThread;
187 inline Work(
Task& t,
bool takeover);
190 inline bool isOK()
const;
195 friend class WorkThread;
205 #define mSTFN(clss,fn) ((::TaskFunction)(&clss::fn)) 206 #define mWMT(obj,clss,fn) ::Threads::Work( obj, mSTFN(clss,fn) ) 212 : obj_( 0 ), cbf_( 0 ), tf_( 0 ), stf_( 0 ) {}
242 const bool res = (
obj_->*
tf_)();
#define mExpClass(module)
Definition: commondefs.h:157
Is an object that faciliates many threads to wait for something to happen.
Definition: thread.h:108
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
TypeSet< int > workqueueid_
Definition: threadwork.h:128
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
Notifier< WorkManager > isShuttingDown
Definition: threadwork.h:114
TypeSet< int > queueids_
Definition: threadwork.h:136
CallBacker * obj_
Definition: threadwork.h:198
bool isOK() const
Definition: threadwork.h:233
void(CallBacker::* CallBackFunction)(CallBacker *)
Definition: callback.h:37
bool(* StaticTaskFunction)()
Definition: threadwork.h:21
Set of BufferString objects.
Definition: bufstringset.h:25
#define mSTFN(clss, fn)
Definition: threadwork.h:205
int nrThreads() const
Definition: threadwork.h:105
CallBackFunction cbf_
Definition: threadwork.h:199
Takes work and puts it on a queue for execution either in parallel, singlethread or manual...
Definition: threadwork.h:37
Work()
Definition: threadwork.h:211
Definition: threadwork.h:45
Class to help setup a callback handling.
Definition: notify.h:121
bool(CallBacker::* TaskFunction)()
Definition: threadwork.h:22
interface to threads that should be portable.
Definition: atomic.h:24
ObjectSet< const void > threadids_
Definition: threadwork.h:132
Set of (small) copyable elements.
Definition: commontypes.h:26
BoolTypeSet queueisclosing_
Definition: threadwork.h:140
const int twmid_
Only for debugging.
Definition: threadwork.h:145
QueueType
Definition: threadwork.h:45
bool takeover_
Definition: threadwork.h:202
TaskFunction tf_
Definition: threadwork.h:200
BufferStringSet queuenames_
Definition: threadwork.h:139
ObjectSet< WorkThread > threads_
Definition: threadwork.h:131
ObjectSet< WorkThread > freethreads_
Definition: threadwork.h:133
ConditionVar & workloadcond_
Definition: threadwork.h:142
TypeSet< QueueType > queuetypes_
Definition: threadwork.h:138
bool doRun()
Definition: threadwork.h:237
static int cDefaultQueueID()
Definition: threadwork.h:58
int freeid_
Definition: threadwork.h:144
Notifier< WorkManager > isidle
Definition: threadwork.h:110
CallBacks object-oriented (object + method).
Definition: callback.h:62
StaticTaskFunction stf_
Definition: threadwork.h:201
Generalization of something (e.g. a computation) that needs to be done in multiple steps...
Definition: task.h:26
TypeSet< int > queueworkload_
Definition: threadwork.h:137
TypeSet< CallBack > callbacks_
Definition: threadwork.h:129
TypeSet< Work > workload_
Definition: threadwork.h:127
The abstraction of something that can be done. It can be an ordinary CallBack, a static function (mus...
Definition: threadwork.h:180