Associates a generic C-style function pointer with an AsyncTask object.
More...
#include "genericAsyncTask.h"
List of all members.
Public Types |
|
typedef void | BirthFunc (GenericAsyncTask *task, void *user_data) |
|
typedef void | DeathFunc (GenericAsyncTask *task, bool clean_exit, void *user_data) |
|
typedef DoneStatus | TaskFunc (GenericAsyncTask *task, void *user_data) |
Public Member Functions |
|
| GenericAsyncTask (const string &name=string()) |
|
| GenericAsyncTask (const string &name, TaskFunc *function, void *user_data) |
|
virtual TypeHandle | force_init_type () |
| TaskFunc * | get_function () const |
| | Returns the function that is called when the task runs.
|
|
virtual TypeHandle | get_type () const |
| BirthFunc * | get_upon_birth () const |
| | Returns the function that is called when the task begins, or NULL if the function is not defined.
|
| DeathFunc * | get_upon_death () const |
| | Returns the function that is called when the task ends, or NULL if the function is not defined.
|
| void * | get_user_data () const |
| | Returns the void pointer that is passed to the task function.
|
| void | set_function (TaskFunc *function) |
| | Replaces the function that is called when the task runs.
|
| void | set_upon_birth (BirthFunc *function) |
| | Replaces the function that is called when the task begins.
|
| void | set_upon_death (DeathFunc *function) |
| | Replaces the function that is called when the task ends.
|
| void | set_user_data (void *user_data) |
| | Replaces the void pointer that is passed to the task function.
|
Static Public Member Functions |
|
static TypeHandle | get_class_type () |
|
static void | init_type () |
Protected Member Functions |
| virtual DoneStatus | do_task () |
| | Override this function to do something useful for the task.
|
| virtual bool | is_runnable () |
| | Override this function to return true if the task can be successfully executed, false if it cannot.
|
| virtual void | upon_birth (AsyncTaskManager *manager) |
| | Override this function to do something useful when the task has been added to the active queue.
|
| virtual void | upon_death (AsyncTaskManager *manager, bool clean_exit) |
| | Override this function to do something useful when the task has been removed from the active queue.
|
Detailed Description
Associates a generic C-style function pointer with an AsyncTask object.
You can use this when you want to create an AsyncTask without having to subclass.
Definition at line 28 of file genericAsyncTask.h.
Member Function Documentation
| AsyncTask::DoneStatus GenericAsyncTask::do_task |
( |
| ) |
[protected, virtual] |
Override this function to do something useful for the task.
This function is called with the lock *not* held.
Reimplemented from AsyncTask.
Definition at line 74 of file genericAsyncTask.cxx.
| GenericAsyncTask::TaskFunc * GenericAsyncTask::get_function |
( |
| ) |
const [inline] |
Returns the function that is called when the task runs.
Definition at line 34 of file genericAsyncTask.I.
| GenericAsyncTask::BirthFunc * GenericAsyncTask::get_upon_birth |
( |
| ) |
const [inline] |
Returns the function that is called when the task begins, or NULL if the function is not defined.
Definition at line 56 of file genericAsyncTask.I.
| GenericAsyncTask::DeathFunc * GenericAsyncTask::get_upon_death |
( |
| ) |
const [inline] |
Returns the function that is called when the task ends, or NULL if the function is not defined.
Definition at line 78 of file genericAsyncTask.I.
| void * GenericAsyncTask::get_user_data |
( |
| ) |
const [inline] |
Returns the void pointer that is passed to the task function.
Definition at line 101 of file genericAsyncTask.I.
| bool GenericAsyncTask::is_runnable |
( |
| ) |
[protected, virtual] |
Override this function to return true if the task can be successfully executed, false if it cannot.
Mainly intended as a sanity check when attempting to add the task to a task manager.
This function is called with the lock held.
Reimplemented from AsyncTask.
Definition at line 61 of file genericAsyncTask.cxx.
| void GenericAsyncTask::set_function |
( |
GenericAsyncTask::TaskFunc * |
function | ) |
[inline] |
Replaces the function that is called when the task runs.
Definition at line 23 of file genericAsyncTask.I.
| void GenericAsyncTask::set_upon_birth |
( |
GenericAsyncTask::BirthFunc * |
upon_birth | ) |
[inline] |
Replaces the function that is called when the task begins.
This is an optional function.
Definition at line 45 of file genericAsyncTask.I.
References upon_birth().
| void GenericAsyncTask::set_upon_death |
( |
GenericAsyncTask::DeathFunc * |
upon_death | ) |
[inline] |
Replaces the function that is called when the task ends.
This is an optional function.
Definition at line 67 of file genericAsyncTask.I.
References upon_death().
| void GenericAsyncTask::set_user_data |
( |
void * |
user_data | ) |
[inline] |
Replaces the void pointer that is passed to the task function.
This is any arbitrary pointer; the task object does no processing on it.
Definition at line 90 of file genericAsyncTask.I.
| void GenericAsyncTask::upon_birth |
( |
AsyncTaskManager * |
manager | ) |
[protected, virtual] |
Override this function to do something useful when the task has been added to the active queue.
This function is called with the lock *not* held.
Reimplemented from AsyncTask.
Definition at line 88 of file genericAsyncTask.cxx.
Referenced by set_upon_birth().
| void GenericAsyncTask::upon_death |
( |
AsyncTaskManager * |
manager, |
|
|
bool |
clean_exit |
|
) |
| [protected, virtual] |
Override this function to do something useful when the task has been removed from the active queue.
The parameter clean_exit is true if the task has been removed because it exited normally (returning DS_done), or false if it was removed for some other reason (e.g. AsyncTaskManager::remove()). By the time this method is called, _manager has been cleared, so the parameter manager indicates the original AsyncTaskManager that owned this task.
The normal behavior is to throw the done_event only if clean_exit is true.
This function is called with the lock *not* held.
Reimplemented from AsyncTask.
Definition at line 115 of file genericAsyncTask.cxx.
Referenced by set_upon_death().
The documentation for this class was generated from the following files: