Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArASyncTask Class Reference

#include <ArASyncTask.h>

Inheritance diagram for ArASyncTask:

ArThread ArFunctorASyncTask ArRecurrentTask ArSignalHandler ArSoundsQueue List of all members.

Detailed Description

Asynchronous task (runs in its own thread).

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.

Examples:

threadExample.cpp.

Definition at line 48 of file ArASyncTask.h.

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.


Member Function Documentation

void * ArASyncTask::runInThisThread void *  arg = 0  )  [virtual]
 

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.

Parameters:
arg the argument to pass to the runThread()

Definition at line 58 of file ArASyncTask.cpp.

virtual void* ArASyncTask::runThread void *  arg  )  [pure virtual]
 

The main run loop.

Override this function and put your taskes run loop here. Check the value of getRunning() periodicly in your loop. If the value is false, the loop should exit and runThread() should return. The argument and return value are specific to the platform thread implementation, and can be ignored.

Java and Python Wrappers: In the wrapper libraries, this method takes no arguments and has no return value.

Implemented in ArFunctorASyncTask, and ArSoundsQueue.


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:43 2007 for Aria by  doxygen 1.4.0