|
|
|
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in the foreground thread) or asynchronously (by a background thread).
More...
#include "asyncTaskManager.h"
List of all members.
Classes |
| class | AsyncTaskSortName |
Public Member Functions |
|
| AsyncTaskManager (const string &name) |
| void | add (AsyncTask *task) |
| | Adds the indicated task to the active queue.
|
| void | cleanup () |
| | Stops all threads and messily empties the task list.
|
| AsyncTask * | find_task (const string &name) const |
| | Returns the first task found with the indicated name, or NULL if there is no task with the indicated name.
|
| AsyncTaskChain * | find_task_chain (const string &name) |
| | Searches a new AsyncTaskChain of the indicated name and returns it if it exists, or NULL otherwise.
|
| AsyncTaskCollection | find_tasks (const string &name) const |
| | Returns the list of tasks found with the indicated name.
|
| AsyncTaskCollection | find_tasks_matching (const GlobPattern &pattern) const |
| | Returns the list of tasks found whose name matches the indicated glob pattern, e.g.
|
|
virtual TypeHandle | force_init_type () |
| AsyncTaskCollection | get_active_tasks () const |
| | Returns the set of tasks that are active (and not sleeping) on the task manager, at the time of the call.
|
| ClockObject * | get_clock () |
| | Returns the clock pointer used within the AsyncTaskManager.
|
| double | get_next_wake_time () const |
| | Returns the scheduled time (on the manager's clock) of the next sleeping task, on any task chain, to awaken.
|
| int | get_num_task_chains () const |
| | Returns the number of different task chains.
|
| int | get_num_tasks () const |
| | Returns the number of tasks that are currently active or sleeping within the task manager.
|
| AsyncTaskCollection | get_sleeping_tasks () const |
| | Returns the set of tasks that are sleeping (and not active) on the task manager, at the time of the call.
|
| AsyncTaskChain * | get_task_chain (int n) const |
| | Returns the nth task chain.
|
| AsyncTaskCollection | get_tasks () const |
| | Returns the set of tasks that are active or sleeping on the task manager, at the time of the call.
|
|
virtual TypeHandle | get_type () const |
| bool | has_task (AsyncTask *task) const |
| | Returns true if the indicated task has been added to this AsyncTaskManager, false otherwise.
|
|
| MAKE_SEQ (get_task_chains, get_num_task_chains, get_task_chain) |
| AsyncTaskChain * | make_task_chain (const string &name) |
| | Creates a new AsyncTaskChain of the indicated name and stores it within the AsyncTaskManager.
|
| virtual void | output (ostream &out) const |
| | Outputs the Namable.
|
| void | poll () |
| | Runs through all the tasks in the task list, once, if the task manager is running in single-threaded mode (no threads available).
|
| bool | remove (AsyncTask *task) |
| | Removes the indicated task from the active queue.
|
| int | remove (const AsyncTaskCollection &tasks) |
| | Removes all of the tasks in the AsyncTaskCollection.
|
| bool | remove_task_chain (const string &name) |
| | Removes the AsyncTaskChain of the indicated name.
|
| void | set_clock (ClockObject *clock) |
| | Replaces the clock pointer used within the AsyncTaskManager.
|
| void | start_threads () |
| | Starts any requested threads to service the tasks on the queue.
|
| void | stop_threads () |
| | Stops any threads that are currently running.
|
| void | wait_for_tasks () |
| | Blocks until the task list is empty.
|
|
virtual void | write (ostream &out, int indent_level=0) const |
Static Public Member Functions |
|
static TypeHandle | get_class_type () |
| static AsyncTaskManager * | get_global_ptr () |
| | Returns a pointer to the global AsyncTaskManager.
|
|
static void | init_type () |
Protected Types |
typedef ov_set< PT(AsyncTaskChain),
IndirectCompareNames
< AsyncTaskChain > > | TaskChains |
typedef pmultiset< AsyncTask
*, AsyncTaskSortName > | TasksByName |
Protected Member Functions |
| void | add_task_by_name (AsyncTask *task) |
| | Adds the task to the _tasks_by_name index, if it has a nonempty name.
|
| AsyncTaskChain * | do_find_task_chain (const string &name) |
| | Searches a new AsyncTaskChain of the indicated name and returns it if it exists, or NULL otherwise.
|
| bool | do_has_task (AsyncTask *task) const |
| | Returns true if the task is on one of the task lists, false if it is not (false may mean that the task is currently being serviced).
|
| AsyncTaskChain * | do_make_task_chain (const string &name) |
| | Creates a new AsyncTaskChain of the indicated name and stores it within the AsyncTaskManager.
|
|
virtual void | do_output (ostream &out) const |
|
| PT (ClockObject) _clock |
| void | remove_task_by_name (AsyncTask *task) |
| | Removes the task from the _tasks_by_name index, if it has a nonempty name.
|
Protected Attributes |
|
ConditionVarFull | _frame_cvar |
|
Mutex | _lock |
|
int | _num_tasks |
|
TaskChains | _task_chains |
|
TasksByName | _tasks_by_name |
Static Protected Attributes |
|
static AsyncTaskManager * | _global_ptr = NULL |
Friends |
|
class | AsyncTask |
|
class | AsyncTaskChain |
|
class | AsyncTaskChain::AsyncTaskChainThread |
|
class | AsyncTaskSequence |
Detailed Description
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in the foreground thread) or asynchronously (by a background thread).
The AsyncTaskManager is actually a collection of AsyncTaskChains, each of which maintains a list of tasks. Each chain can be either foreground or background (it may run only in the main thread, or it may be serviced by one or more background threads). See AsyncTaskChain for more information.
If you do not require background processing, it is perfectly acceptable to create only one AsyncTaskChain, which runs in the main thread. This is a common configuration.
Definition at line 54 of file asyncTaskManager.h.
Member Function Documentation
Returns the first task found with the indicated name, or NULL if there is no task with the indicated name.
If there are multiple tasks with the same name, returns one of them arbitrarily.
Definition at line 279 of file asyncTaskManager.cxx.
References ReferenceCount::local_object().
Returns the number of tasks that are currently active or sleeping within the task manager.
Definition at line 50 of file asyncTaskManager.I.
Replaces the clock pointer used within the AsyncTaskManager.
This is used to control when tasks with a set_delay() specified will be scheduled. It can also be ticked automatically each epoch, if set_tick_clock() is true.
The default is the global clock pointer.
Definition at line 28 of file asyncTaskManager.I.
The documentation for this class was generated from the following files:
| | |