#include <ArASyncTask.h>
Inheritance diagram for ArASyncTask:
Public Member Functions | |
ArASyncTask () | |
Constructor. | |
virtual int | create (bool joinable=true, bool lowerPriority=true) |
Create the task and start it going. | |
virtual void | run (void) |
Run in this thread. | |
virtual void | runAsync (void) |
Run in its own thread. | |
virtual void * | runInThisThread (void *arg=0) |
Run the code of the task syncronously. | |
virtual void * | runThread (void *arg)=0 |
The main run loop. | |
virtual void | stopRunning (void) |
Stop the thread. | |
virtual | ~ArASyncTask () |
Destructor. |
The ArAsynTask is a task that runs in its own thread. This is a rather simple class. The user simply needs to derive their own class from ArAsyncTask and define the runThread() function. They then need to create an instance of their task and call run or runAsync. The standard way to stop a task is to call stopRunning() which sets ArThread::myRunning to false. In their run loop, they should pay attention to the getRunning() or the ArThread::myRunning variable. If this value goes to false, the task should clean up after itself and exit its runThread() function.
Definition at line 49 of file ArASyncTask.h.
|
Run the code of the task syncronously. This will run the code of the ArASyncTask without creating a new thread to run it in. It performs the needed setup then calls runThread(). This is good if you have a task which you wish to run multiple instances of and you want to use the main() thread instead of having it block, waiting for exit of the program.
Definition at line 59 of file ArASyncTask.cpp. References ArMutex::lock(), ArLog::log(), runThread(), and ArMutex::unlock(). Referenced by ArSoundsQueue::run(), and run(). |
|
The main run loop. Override this function and put your taskes run loop here. Check the value of getRunning() or myRunning periodicly in your loop. If the value goes false, the loop should exit and runThread() should return. Implemented in ArFunctorASyncTask, ArRecurrentTask, ArSignalHandler, and ArSoundsQueue. Referenced by runInThisThread(). |