Eclipse SUMO - Simulation of Urban MObility
MFXWorkerThread::Task Class Referenceabstract

Abstract superclass of a task to be run with an index to keep track of pending tasks. More...

#include <MFXWorkerThread.h>

Public Member Functions

virtual void run (MFXWorkerThread *context)=0
 Abstract method which in subclasses should contain the computations to be performed. More...
 
void setIndex (const int newIndex)
 Sets the running index of this task. More...
 
virtual ~Task ()
 Desctructor. More...
 

Private Attributes

int myIndex
 the index of the task, valid only after the task has been added to the pool More...
 

Detailed Description

Abstract superclass of a task to be run with an index to keep track of pending tasks.

Definition at line 53 of file MFXWorkerThread.h.

Constructor & Destructor Documentation

◆ ~Task()

virtual MFXWorkerThread::Task::~Task ( )
inlinevirtual

Desctructor.

Definition at line 56 of file MFXWorkerThread.h.

Member Function Documentation

◆ run()

virtual void MFXWorkerThread::Task::run ( MFXWorkerThread context)
pure virtual

Abstract method which in subclasses should contain the computations to be performed.

If there is data to be shared among several tasks (but not among several threads) it can be put in the a thread class subclassing the MFXWorkerThread. the instance of the thread is then made available via the context parameter.

Parameters
[in]contextThe thread which runs the task

◆ setIndex()

void MFXWorkerThread::Task::setIndex ( const int  newIndex)
inline

Sets the running index of this task.

Every task receive an index which is unique among all pending tasks of the same thread pool.

Parameters
[in]newIndexthe index to assign

Definition at line 74 of file MFXWorkerThread.h.

References myIndex.

Referenced by MFXWorkerThread::Pool::add().

Here is the caller graph for this function:

Field Documentation

◆ myIndex

int MFXWorkerThread::Task::myIndex
private

the index of the task, valid only after the task has been added to the pool

Definition at line 79 of file MFXWorkerThread.h.

Referenced by setIndex().


The documentation for this class was generated from the following file: