19 class ParallelTaskRunner;
71 bool execute() {
return executeParallel(
true); }
77 virtual bool executeParallel(
bool parallel);
94 virtual od_int64 nrIterations()
const = 0;
97 virtual int maxNrThreads()
const;
114 void addToNrDone(
od_int64 increment);
119 void quickAddToNrDone(
od_int64 loopidx);
136 virtual bool doFinish(
bool success) {
return success; }
141 friend class ParallelTaskRunner;
181 #define mDeclareParallelCalcStd(uimsg) \ 183 bool reportprogress_; \ 184 void setReport(bool yn) { reportprogress_ = yn; } \ 185 od_int64 nrIterations() const { return sz_; } \ 186 uiString uiMessage() const { return uimsg; } \ 187 uiString uiNrDoneText() const { return sPosFinished(); } \ 189 #define mDefParallelCalcNoPars(clss,uimsg) \ 190 class clss : public ParallelTask \ 191 { mODTextTranslationClass(clss); \ 193 mDeclareParallelCalcStd(uimsg); \ 194 clss( od_int64 _sz_ ) : sz_(_sz_), reportprogress_(true) {} \ 196 #define mDefParallelCalc1Par(clss,uimsg,T1,v1) \ 197 class clss : public ParallelTask \ 198 { mODTextTranslationClass(clss); \ 200 mDeclareParallelCalcStd(uimsg); \ 202 clss( od_int64 _sz_, T1 _##v1##_ ) \ 203 : sz_(_sz_), reportprogress_(true), v1##_(_##v1##_) {} \ 205 #define mDefParallelCalc2Pars(clss,uimsg,T1,v1,T2,v2) \ 206 class clss : public ParallelTask \ 207 { mODTextTranslationClass(clss); \ 209 mDeclareParallelCalcStd(uimsg); \ 210 T1 v1##_; T2 v2##_; \ 211 clss( od_int64 _sz_, T1 _##v1##_, T2 _##v2##_ ) \ 212 : sz_(_sz_), reportprogress_(true) \ 213 , v1##_(_##v1##_), v2##_(_##v2##_) {} \ 215 #define mDefParallelCalc3Pars(clss,uimsg,T1,v1,T2,v2,T3,v3) \ 216 class clss : public ParallelTask \ 217 { mODTextTranslationClass(clss); \ 219 mDeclareParallelCalcStd(uimsg); \ 220 T1 v1##_; T2 v2##_; T3 v3##_; \ 221 clss( od_int64 _sz_, \ 222 T1 _##v1##_, T2 _##v2##_, T3 _##v3##_ ) \ 223 : sz_(_sz_), reportprogress_(true) \ 224 , v1##_(_##v1##_), v2##_(_##v2##_) , v3##_(_##v3##_) {} \ 226 #define mDefParallelCalc4Pars(clss,uimsg,T1,v1,T2,v2,T3,v3,T4,v4) \ 227 class clss : public ParallelTask \ 228 { mODTextTranslationClass(clss); \ 230 mDeclareParallelCalcStd(uimsg); \ 231 T1 v1##_; T2 v2##_; T3 v3##_; T4 v4##_; \ 232 clss( od_int64 _sz_, \ 233 T1 _##v1##_, T2 _##v2##_, T3 _##v3##_, T4 _##v4##_ ) \ 234 : sz_(_sz_), reportprogress_(true) \ 235 , v1##_(_##v1##_), v2##_(_##v2##_) \ 236 , v3##_(_##v3##_), v4##_(_##v4##_) {} \ 239 #define mDefParallelCalc5Pars(clss,uimsg,T1,v1,T2,v2,T3,v3,T4,v4,T5,v5) \ 240 class clss : public ParallelTask \ 241 { mODTextTranslationClass(clss); \ 243 mDeclareParallelCalcStd(uimsg); \ 244 T1 v1##_; T2 v2##_; T3 v3##_; T4 v4##_; T5 v5##_;\ 245 clss( od_int64 _sz_, T1 _##v1##_, T2 _##v2##_, T3 _##v3##_, \ 246 T4 _##v4##_, T5 _##v5##_ ) \ 247 : sz_(_sz_), reportprogress_(true) \ 248 , v1##_(_##v1##_), v2##_(_##v2##_) \ 249 , v3##_(_##v3##_), v4##_(_##v4##_), v5##_(_##v5##_) {} \ 251 #define mDefParallelCalc6Pars(clss,uimsg,T1,v1,T2,v2,T3,v3,T4,v4,T5,v5,T6,v6) \ 252 class clss : public ParallelTask \ 253 { mODTextTranslationClass(clss); \ 255 mDeclareParallelCalcStd(uimsg); \ 256 T1 v1##_; T2 v2##_; T3 v3##_; T4 v4##_; T5 v5##_; T6 v6##_;\ 257 clss( od_int64 _sz_, T1 _##v1##_, T2 _##v2##_, T3 _##v3##_, \ 258 T4 _##v4##_, T5 _##v5##_, T6 _##v6##_ ) \ 259 : sz_(_sz_), reportprogress_(true) \ 260 , v1##_(_##v1##_), v2##_(_##v2##_) \ 261 , v3##_(_##v3##_), v4##_(_##v4##_) \ 262 , v5##_(_##v5##_), v6##_(_##v6##_) {} \ 264 #define mDefParallelCalc7Pars(clss,uimsg,T1,v1,T2,v2,T3,v3,T4,v4,T5,v5, \ 266 class clss : public ParallelTask \ 267 { mODTextTranslationClass(clss); \ 269 mDeclareParallelCalcStd(uimsg); \ 270 T1 v1##_; T2 v2##_; T3 v3##_; T4 v4##_; \ 271 T5 v5##_; T6 v6##_; T7 v7##_; \ 272 clss( od_int64 _sz_, T1 _##v1##_, T2 _##v2##_, T3 _##v3##_, \ 273 T4 _##v4##_, T5 _##v5##_, T6 _##v6##_, T7 _##v7##_ ) \ 274 : sz_(_sz_), reportprogress_(true) \ 275 , v1##_(_##v1##_), v2##_(_##v2##_) \ 276 , v3##_(_##v3##_), v4##_(_##v4##_) \ 277 , v5##_(_##v5##_), v6##_(_##v6##_), v7##_(_##v7##_) {} \ 279 #define mDefParallelCalcBody(preop,impl,postop) \ 280 bool doWork( od_int64 start, od_int64 stop, int ) \ 283 for ( od_int64 idx=start; idx<=stop; idx++ ) \ 284 { impl; if ( reportprogress_ ) quickAddToNrDone(idx); } \ #define mExpClass(module)
Definition: commondefs.h:160
virtual bool stopAllOnFailure() const
Definition: paralleltask.h:103
static uiString sTrcFinished()
Definition: paralleltask.h:90
is an interface where processes can report their progress.
Definition: progressmeter.h:21
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
ProgressMeter * progressmeter_
Definition: paralleltask.h:142
#define od_int64
Definition: plftypes.h:36
Definition: uistring.h:89
Threads::Atomic< int64_t > nrdone_
Definition: paralleltask.h:143
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
virtual int minThreadSize() const
Definition: paralleltask.h:98
static uiString sPosFinished()
Definition: paralleltask.h:89
bool execute()
Definition: paralleltask.h:71
virtual bool doFinish(bool success)
Definition: paralleltask.h:136
int64_t totalNr() const
Definition: paralleltask.h:88
int64_t totalnrcache_
Definition: paralleltask.h:147
virtual bool doPrepare(int nrthreads)
Definition: paralleltask.h:134
Generalization of something (e.g. a computation) that needs to be done in multiple steps...
Definition: task.h:28
int64_t nrdonebigchunksz_
Definition: paralleltask.h:148