Panda3D
|
A special kind of task that serves as a list of tasks internally. More...
Public Types | |
enum | DoneStatus { DSDone = 0, DSCont = 1, DSAgain = 2, DSPickup = 3, DSExit = 4, DSPause = 5, DSInterrupt = 6 } |
enum | State { SInactive = 0, SActive = 1, SServicing = 2, SServicingRemoved = 3, SSleeping = 4, SActiveNested = 5 } |
Public Member Functions | |
AsyncTaskSequence (string name) | |
addTask (AsyncTask task) | |
Adds a new AsyncTask to the collection. | |
addTasksFrom (AsyncTaskCollection const other) | |
Adds all the AsyncTasks indicated in the other collection to this task. | |
clear () | |
Removes all AsyncTasks from the collection. | |
clearDelay () | |
Removes any delay specified for the task. | |
clearName () | |
Resets the task's name to empty. | |
AsyncTask | findTask (string name) |
Returns the task in the collection with the indicated name, if any, or NULL if no task has that name. | |
double | getAverageDt () |
Returns the average amount of time elapsed during each of the task's previous run cycles, in seconds. | |
int | getCurrentTaskIndex () |
Returns the index of the task within the sequence that is currently being executed (or that will be executed at the next epoch). | |
double | getDelay () |
Returns the delay value that has been set via set_delay, if any. | |
string | getDoneEvent () |
Returns the event name that will be triggered when the task finishes. | |
double | getDt () |
Returns the amount of time elapsed during the task's previous run cycle, in seconds. | |
int | getElapsedFrames () |
Returns the number of frames that have elapsed since the task was started, according to the task manager's clock. | |
double | getElapsedTime () |
Returns the amount of time that has elapsed since the task was started, according to the task manager's clock. | |
AsyncTaskManager | getManager () |
Returns the AsyncTaskManager that this task is active on. | |
double | getMaxDt () |
Returns the maximum amount of time elapsed during any one of the task's previous run cycles, in seconds. | |
string | getName () |
string | getNamePrefix () |
Returns the initial part of the name, up to but not including any trailing digits following a hyphen or underscore. | |
int | getNumTasks () |
Returns the number of AsyncTasks in the collection. | |
int | getPriority () |
Returns the task's current priority value. | |
PyObject | getPythonObject () |
Returns the Python object that was specified to set_python_object(), if any, or None if no object was specified. | |
int | getRefCount () |
Returns the current reference count. | |
int | getRepeatCount () |
Returns the repeat count of the sequence. | |
int | getSort () |
Returns the task's current sort value. | |
int | getStartFrame () |
Returns the frame number at which the task was started, according to the task manager's clock. | |
double | getStartTime () |
Returns the time at which the task was started, according to the task manager's clock. | |
State | getState () |
Returns the current state of the task. | |
AsyncTask | getTask (int index) |
Returns the nth AsyncTask in the collection. | |
string | getTaskChain () |
Returns the AsyncTaskChain on which this task will be running. | |
long int | getTaskId () |
Returns a number guaranteed to be unique for each different AsyncTask object in the universe. | |
list | getTasks () |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
double | getWakeTime () |
If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken. | |
bool | hasDelay () |
Returns true if a delay has been set for this task via set_delay(), or false otherwise. | |
bool | hasName () |
Returns true if the Namable has a nonempty name set, false if the name is empty. | |
bool | hasTask (AsyncTask task) |
Returns true if the indicated AsyncTask appears in this collection, false otherwise. | |
bool | isAlive () |
Returns true if the task is currently active or sleeping on some task chain, meaning that it will be executed in its turn, or false if it is not active. | |
bool | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. | |
operator new (unsigned int size) | |
AsyncTaskCollection | operator+ (AsyncTaskCollection const other) |
Returns a AsyncTaskCollection representing the concatenation of the two lists. | |
AsyncTaskCollection | operator+= (AsyncTaskCollection const other) |
Appends the other list onto the end of this one. | |
AsyncTask | operator[] (int index) |
Returns the nth AsyncTask in the collection. | |
output (ostream out) | |
Writes a brief one-line description of the AsyncTaskCollection to the indicated output stream. | |
output (ostream out) | |
Outputs the Namable. | |
recalcWakeTime () | |
If the task is currently sleeping on a task chain, this resets its wake time to the current time + get_delay(). | |
ref () | |
Explicitly increments the reference count. | |
remove () | |
Removes the task from its active manager, if any, and makes the state S_inactive (or possible S_servicing_removed). | |
removeDuplicateTasks () | |
Removes any duplicate entries of the same AsyncTasks on this collection. | |
removeTask (int index) | |
Removes the nth AsyncTask from the collection. | |
bool | removeTask (AsyncTask task) |
Removes the indicated AsyncTask from the collection. | |
removeTasksFrom (AsyncTaskCollection const other) | |
Removes from this collection all of the AsyncTasks listed in the other collection. | |
setDelay (double delay) | |
Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager. | |
setDoneEvent (string done_event) | |
Sets the event name that will be triggered when the task finishes. | |
setName (string name) | |
setPriority (int priority) | |
Specifies a priority value for this task. | |
setPythonObject (PyObject python_object) | |
Specifies an arbitrary Python object that will be piggybacked on the task object. | |
setRepeatCount (int repeat_count) | |
Sets the repeat count of the sequence. | |
setSort (int sort) | |
Specifies a sort value for this task. | |
setTaskChain (string chain_name) | |
Specifies the AsyncTaskChain on which this task will be running. | |
int | size () |
Returns the number of tasks in the collection. | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
bool | unref () |
Explicitly decrements the reference count. | |
write (ostream out, int indent_level) | |
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream. | |
write (ostream out) | |
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream. | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
A special kind of task that serves as a list of tasks internally.
Each task on the list is executed in sequence, one per epoch.
This is similar to a Sequence interval, though it has some slightly different abilities. For instance, although you can't start at any arbitrary point in the sequence, you can construct a task sequence whose duration changes during playback.
enum DoneStatus [inherited] |
enum State [inherited] |
AsyncTaskSequence | ( | string | name | ) |
addTasksFrom | ( | AsyncTaskCollection const | other | ) | [inherited] |
Adds all the AsyncTasks indicated in the other collection to this task.
The other tasks are simply appended to the end of the tasks in this list; duplicates are not automatically removed.
clear | ( | ) | [inherited] |
Removes all AsyncTasks from the collection.
clearDelay | ( | ) | [inherited] |
Removes any delay specified for the task.
The next time the task is added to the queue, it will run immediately. This does not affect the task's wake time if it has already been added to the queue.
clearName | ( | ) | [inherited] |
Resets the task's name to empty.
Reimplemented from Namable.
AsyncTask findTask | ( | string | name | ) | [inherited] |
Returns the task in the collection with the indicated name, if any, or NULL if no task has that name.
double getAverageDt | ( | ) | [inherited] |
Returns the average amount of time elapsed during each of the task's previous run cycles, in seconds.
static TypeHandle getClassType | ( | ) | [static] |
Reimplemented from AsyncTask.
int getCurrentTaskIndex | ( | ) |
Returns the index of the task within the sequence that is currently being executed (or that will be executed at the next epoch).
double getDelay | ( | ) | [inherited] |
Returns the delay value that has been set via set_delay, if any.
string getDoneEvent | ( | ) | [inherited] |
Returns the event name that will be triggered when the task finishes.
See set_done_event().
double getDt | ( | ) | [inherited] |
Returns the amount of time elapsed during the task's previous run cycle, in seconds.
int getElapsedFrames | ( | ) | [inherited] |
Returns the number of frames that have elapsed since the task was started, according to the task manager's clock.
It is only valid to call this if the task's status is not S_inactive.
double getElapsedTime | ( | ) | [inherited] |
Returns the amount of time that has elapsed since the task was started, according to the task manager's clock.
It is only valid to call this if the task's status is not S_inactive.
AsyncTaskManager getManager | ( | ) | [inherited] |
Returns the AsyncTaskManager that this task is active on.
This will be NULL if the state is S_inactive.
double getMaxDt | ( | ) | [inherited] |
Returns the maximum amount of time elapsed during any one of the task's previous run cycles, in seconds.
string getName | ( | ) | [inherited] |
Reimplemented in DynamicTextFont.
string getNamePrefix | ( | ) | [inherited] |
Returns the initial part of the name, up to but not including any trailing digits following a hyphen or underscore.
int getNumTasks | ( | ) | [inherited] |
Returns the number of AsyncTasks in the collection.
int getPriority | ( | ) | [inherited] |
Returns the task's current priority value.
See set_priority().
PyObject getPythonObject | ( | ) | [inherited] |
Returns the Python object that was specified to set_python_object(), if any, or None if no object was specified.
int getRefCount | ( | ) | [inherited] |
Returns the current reference count.
int getRepeatCount | ( | ) |
Returns the repeat count of the sequence.
See set_repeat_count().
int getSort | ( | ) | [inherited] |
Returns the task's current sort value.
See set_sort().
int getStartFrame | ( | ) | [inherited] |
Returns the frame number at which the task was started, according to the task manager's clock.
It is only valid to call this if the task's status is not S_inactive.
double getStartTime | ( | ) | [inherited] |
Returns the time at which the task was started, according to the task manager's clock.
It is only valid to call this if the task's status is not S_inactive.
State getState | ( | ) | [inherited] |
Returns the current state of the task.
string getTaskChain | ( | ) | [inherited] |
Returns the AsyncTaskChain on which this task will be running.
Each task chain runs tasks independently of the others.
long int getTaskId | ( | ) | [inherited] |
Returns a number guaranteed to be unique for each different AsyncTask object in the universe.
list getTasks | ( | ) | [inherited] |
TypeHandle getType | ( | ) | [inherited] |
Reimplemented in AnimChannelBase.
int getTypeIndex | ( | ) | [inherited] |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
This is equivalent to get_type().get_index().
double getWakeTime | ( | ) | [inherited] |
If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken.
It has no meaning if the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added.
If the task's status is not S_sleeping, this returns 0.0.
bool hasDelay | ( | ) | [inherited] |
Returns true if a delay has been set for this task via set_delay(), or false otherwise.
bool hasName | ( | ) | [inherited] |
Returns true if the Namable has a nonempty name set, false if the name is empty.
bool hasTask | ( | AsyncTask | task | ) | [inherited] |
Returns true if the indicated AsyncTask appears in this collection, false otherwise.
bool isAlive | ( | ) | [inherited] |
Returns true if the task is currently active or sleeping on some task chain, meaning that it will be executed in its turn, or false if it is not active.
If the task has recently been removed while it is in the middle of execution, this will return false, because the task will not run again once it finishes.
bool isExactType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is the indicated type exactly.
bool isOfType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is or derives from the indicated type.
operator new | ( | unsigned int | size | ) |
AsyncTaskCollection operator+ | ( | AsyncTaskCollection const | other | ) | [inherited] |
Returns a AsyncTaskCollection representing the concatenation of the two lists.
AsyncTaskCollection operator+= | ( | AsyncTaskCollection const | other | ) | [inherited] |
Appends the other list onto the end of this one.
Returns the nth AsyncTask in the collection.
This is the same as get_task(), but it may be a more convenient way to access it.
output | ( | ostream | out | ) | [inherited] |
Writes a brief one-line description of the AsyncTaskCollection to the indicated output stream.
output | ( | ostream | out | ) | [inherited] |
recalcWakeTime | ( | ) | [inherited] |
If the task is currently sleeping on a task chain, this resets its wake time to the current time + get_delay().
It is as if the task had suddenly returned DS_again. The task will sleep for its current delay seconds before running again. This method may therefore be used to make the task wake up sooner or later than it would have otherwise.
If the task is not already sleeping, this method has no effect.
ref | ( | ) | [inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
remove | ( | ) | [inherited] |
Removes the task from its active manager, if any, and makes the state S_inactive (or possible S_servicing_removed).
This is a no-op if the state is already S_inactive.
removeDuplicateTasks | ( | ) | [inherited] |
Removes any duplicate entries of the same AsyncTasks on this collection.
If a AsyncTask appears multiple times, the first appearance is retained; subsequent appearances are removed.
bool removeTask | ( | AsyncTask | task | ) | [inherited] |
Removes the indicated AsyncTask from the collection.
Returns true if the task was removed, false if it was not a member of the collection.
removeTasksFrom | ( | AsyncTaskCollection const | other | ) | [inherited] |
Removes from this collection all of the AsyncTasks listed in the other collection.
setDelay | ( | double | delay | ) | [inherited] |
Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager.
At least the specified amount of time (and possibly more) will elapse before the task begins.
You may specify a delay of 0.0 to guarantee that the task will run in the next epoch following the one in which it is added.
Setting this value after the task has already been added will not affect the task's wake time; it will only affect the task if it is re-added to the queue in the future, for instance if the task returns DS_again. However, see recalc_wake_time() if you wish to apply the delay effect immediately.
setDoneEvent | ( | string | done_event | ) | [inherited] |
Sets the event name that will be triggered when the task finishes.
This should only be called before the task has been started, or after it has finished and before it is about to be restarted (i.e. when get_state() returns S_inactive).
setName | ( | string | name | ) | [inherited] |
Reimplemented from Namable.
setPriority | ( | int | priority | ) | [inherited] |
Specifies a priority value for this task.
In general, tasks with a higher priority value are executed before tasks with a lower priority value (but only for tasks with the same sort value).
Unlike the sort value, tasks with different priorities may execute at the same time, if the AsyncTaskManager has more than one thread servicing tasks.
Also see AsyncTaskChain.set_timeslice_priority(), which changes the meaning of this value. In the default mode, when the timeslice_priority flag is false, all tasks always run once per epoch, regardless of their priority values (that is, the priority controls the order of the task execution only, not the number of times it runs). On the other hand, if you set the timeslice_priority flag to true, then changing a task's priority has an effect on the number of times it runs.
setPythonObject | ( | PyObject | python_object | ) | [inherited] |
Specifies an arbitrary Python object that will be piggybacked on the task object.
setRepeatCount | ( | int | repeat_count | ) |
Sets the repeat count of the sequence.
If the count is 0 or 1, the sequence will run exactly once. If it is greater than 0, it will run that number of times. If it is negative, it will run forever until it is explicitly removed.
setSort | ( | int | sort | ) | [inherited] |
Specifies a sort value for this task.
Within a given AsyncTaskManager, all of the tasks with a given sort value are guaranteed to be completed before any tasks with a higher sort value are begun.
To put it another way, two tasks might execute in parallel with each other only if they both have the same sort value. Tasks with a lower sort value are executed first.
This is different from the priority, which makes no such exclusion guarantees.
setTaskChain | ( | string | chain_name | ) | [inherited] |
Specifies the AsyncTaskChain on which this task will be running.
Each task chain runs tasks independently of the others.
int size | ( | ) | [inherited] |
Returns the number of tasks in the collection.
This is the same thing as get_num_tasks().
bool testRefCountIntegrity | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
bool testRefCountNonzero | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
bool unref | ( | ) | [inherited] |
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream.
write | ( | ostream | out | ) | [inherited] |
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream.