Task of a parallel loop. More...
#include <ParallelLoop.h>
Signals | |
void | progressChanged (int value) |
void | progressInit (int maximumValue) |
void | statusChanged (QString msg) |
Public Member Functions | |
LoopTask () | |
void | setEndIndex (int index) |
void | setIndex (int *index, QMutex *mutex) |
void | terminate () |
bool | terminated () |
Protected Member Functions | |
int | endIndex () const |
virtual void | run () |
virtual void | run (int index)=0 |
void | setProgressMaximum (int value) |
void | setProgressValue (int value) |
void | setStatus (QString msg) |
Task of a parallel loop.
QGpCoreTools::LoopTask::LoopTask | ( | ) | [inline] |
: Thread() {_terminated=false;}
int QGpCoreTools::LoopTask::endIndex | ( | ) | const [inline, protected] |
Returns the final index of the loop. It is the same for all children LoopTask. This might be usefull to revert the order of execution in run(int index) implementations.
Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), and SPACLoopTask::run().
{return _endIndex;}
void QGpCoreTools::LoopTask::progressChanged | ( | int | value | ) | [signal] |
Referenced by setProgressValue().
void QGpCoreTools::LoopTask::progressInit | ( | int | maximumValue | ) | [signal] |
void QGpCoreTools::LoopTask::run | ( | ) | [protected, virtual] |
References terminated(), and TRACE.
{ TRACE; while(true) { if(terminated()) break; _indexMutex->lock(); int i=*_index; (*_index)++; _indexMutex->unlock(); if(i<_endIndex) run(i); else break; } }
virtual void QGpCoreTools::LoopTask::run | ( | int | index | ) | [protected, pure virtual] |
Implemented in SPACLoopTask, FKLoopTask, and LinearFKPassiveLoopTask.
void QGpCoreTools::LoopTask::setEndIndex | ( | int | index | ) | [inline] |
{_endIndex=index;}
void QGpCoreTools::LoopTask::setIndex | ( | int * | index, |
QMutex * | mutex | ||
) | [inline] |
Referenced by QGpCoreTools::ParallelLoop::start().
{_index=index; _indexMutex=mutex;}
void QGpCoreTools::LoopTask::setProgressMaximum | ( | int | value | ) | [inline, protected] |
Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), and SPACLoopTask::run().
{emit progressInit(value);}
void QGpCoreTools::LoopTask::setProgressValue | ( | int | value | ) | [inline, protected] |
References progressChanged(), and TRACE.
Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), and SPACLoopTask::run().
{ TRACE; int now=time(0); if(_lastProgressTime.fetchAndStoreOrdered(now)!=now) { progressChanged(value); } }
void QGpCoreTools::LoopTask::setStatus | ( | QString | msg | ) | [inline, protected] |
Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), and SPACLoopTask::run().
{emit statusChanged(msg);}
void QGpCoreTools::LoopTask::statusChanged | ( | QString | msg | ) | [signal] |
void QGpCoreTools::LoopTask::terminate | ( | ) | [inline] |
{_terminated.fetchAndStoreOrdered(true);}
bool QGpCoreTools::LoopTask::terminated | ( | ) | [inline] |
Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), SPACLoopTask::run(), and run().
{return _terminated.testAndSetOrdered(true,true);}