![]() |
SUMO - Simulation of Urban MObility
|
A thread repeatingly calculating incoming tasks. More...
#include <FXWorkerThread.h>
Data Structures | |
class | Pool |
A pool of worker threads which distributes the tasks and collects the results. More... | |
class | Task |
Abstract superclass of a task to be run with an index to keep track of pending tasks. More... | |
Public Member Functions | |
void | add (Task *t) |
Adds the given task to this thread to be calculated. More... | |
FXWorkerThread (Pool &pool) | |
Constructor. More... | |
FXint | run () |
Main execution method of this thread. More... | |
void | stop () |
Stops the thread. More... | |
virtual | ~FXWorkerThread () |
Destructor. More... | |
Private Attributes | |
FXCondition | myCondition |
the semaphore when waiting for new tasks More... | |
int | myCounter |
counting completed tasks for debugging / profiling More... | |
FXMutex | myMutex |
the mutex for the task list More... | |
Pool & | myPool |
the pool for this thread More... | |
bool | myStopped |
whether we are still running More... | |
std::list< Task * > | myTasks |
the list of pending tasks More... | |
A thread repeatingly calculating incoming tasks.
Definition at line 46 of file FXWorkerThread.h.
|
inline |
Constructor.
Adds the thread to the given pool and starts it.
[in] | pool | the pool for this thread |
Definition at line 226 of file FXWorkerThread.h.
References FXWorkerThread::Pool::addWorker().
Referenced by FXWorkerThread::Pool::Pool().
|
inlinevirtual |
Destructor.
Stops the thread by calling stop.
Definition at line 235 of file FXWorkerThread.h.
References stop().
|
inline |
Adds the given task to this thread to be calculated.
[in] | t | the task to add |
Definition at line 243 of file FXWorkerThread.h.
References myCondition, myMutex, and myTasks.
|
inline |
Main execution method of this thread.
Checks for new tasks, calculates them and puts them in the finished list of the pool until being stopped.
Definition at line 256 of file FXWorkerThread.h.
References FXWorkerThread::Pool::addFinished(), myCondition, myCounter, myMutex, myPool, myStopped, myTasks, and FXWorkerThread::Task::run().
|
inline |
Stops the thread.
The currently running task will be finished but all further tasks are discarded.
Definition at line 282 of file FXWorkerThread.h.
References myCondition, myMutex, and myStopped.
Referenced by ~FXWorkerThread().
|
private |
the semaphore when waiting for new tasks
Definition at line 296 of file FXWorkerThread.h.
Referenced by add(), FXWorkerThread::Pool::addFinished(), run(), stop(), and FXWorkerThread::Pool::waitAll().
|
private |
counting completed tasks for debugging / profiling
Definition at line 302 of file FXWorkerThread.h.
Referenced by run().
|
private |
the mutex for the task list
Definition at line 294 of file FXWorkerThread.h.
Referenced by add(), FXWorkerThread::Pool::addFinished(), run(), stop(), and FXWorkerThread::Pool::waitAll().
|
private |
|
private |
whether we are still running
Definition at line 300 of file FXWorkerThread.h.
|
private |
the list of pending tasks
Definition at line 298 of file FXWorkerThread.h.