All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Signals | Public Member Functions | Protected Member Functions
QGpCoreTools::LoopTask Class Reference

Task of a parallel loop. More...

#include <ParallelLoop.h>

Inheritance diagram for QGpCoreTools::LoopTask:
QGpCoreTools::Thread FKLoopTask SPACLoopTask HRFKLoopTask LinearFKPassiveLoopTask

List of all members.

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)

Detailed Description

Task of a parallel loop.


Constructor & Destructor Documentation

: Thread() {_terminated=false;}

Member Function Documentation

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]
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]
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]
void QGpCoreTools::LoopTask::statusChanged ( QString  msg) [signal]
{_terminated.fetchAndStoreOrdered(true);}

Referenced by LinearFKPassiveLoopTask::run(), FKLoopTask::run(), SPACLoopTask::run(), and run().

{return _terminated.testAndSetOrdered(true,true);}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines