32class EXPCL_PANDA_EVENT AsyncTask :
public AsyncFuture,
public Namable {
34 AsyncTask(
const std::string &name = std::string());
35 ALLOC_DELETED_CHAIN(AsyncTask);
79 void set_name(
const std::string &name);
96 INLINE
double get_dt()
const;
100 virtual void output(std::ostream &out)
const;
108 MAKE_PROPERTY(name, get_name, set_name);
124 void jump_to_task_chain(AsyncTaskManager *manager);
125 DoneStatus unlock_and_do_task();
127 virtual bool cancel() final;
128 virtual
bool is_task() const final {
return true;}
130 virtual bool is_runnable();
131 virtual DoneStatus do_task();
136 AtomicAdjust::Integer _task_id;
137 std::string _chain_name;
143 unsigned int _implicit_sort;
146 Thread *_servicing_thread;
157 static AtomicAdjust::Integer _next_task_id;
162 friend class PythonTask;
168 static void init_type() {
169 AsyncFuture::init_type();
171 AsyncFuture::get_class_type());
173 virtual TypeHandle get_type()
const {
174 return get_class_type();
176 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
179 static TypeHandle _type_handle;
181 friend class AsyncFuture;
182 friend class AsyncTaskManager;
183 friend class AsyncTaskChain;
184 friend class AsyncTaskSequence;
187INLINE std::ostream &operator << (std::ostream &out,
const AsyncTask &task) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool cancel()
Cancels the future.
set_done_event
Sets the event name that will be triggered when the future finishes.
The AsyncTaskChain is a subset of the AsyncTaskManager.
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
This class represents a concrete task performed by an AsyncManager.
set_done_event
Sets the event name that will be triggered when the task finishes.
get_state
Returns the current state of the task.
int get_elapsed_frames() const
Returns the number of frames that have elapsed since the task was started, according to the task mana...
set_task_chain
Specifies the AsyncTaskChain on which this task will be running.
get_task_chain
Returns the AsyncTaskChain on which this task will be running.
get_max_dt
Returns the maximum amount of time elapsed during any one of the task's previous run cycles,...
double get_elapsed_time() const
Returns the amount of time that has elapsed since the task was started, according to the task manager...
get_priority
Returns the task's current priority value.
get_average_dt
Returns the average amount of time elapsed during each of the task's previous run cycles,...
bool has_delay() const
Returns true if a delay has been set for this task via set_delay(), or false otherwise.
get_task_id
Returns a number guaranteed to be unique for each different AsyncTask object in the universe.
get_sort
Returns the task's current sort value.
double get_wake_time() const
If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at w...
get_dt
Returns the amount of time elapsed during the task's previous run cycle, in seconds.
bool remove()
Removes the task from its active manager, if any, and makes the state S_inactive (or possible S_servi...
is_alive
Returns true if the task is currently active or sleeping on some task chain, meaning that it will be ...
void clear_delay()
Removes any delay specified for the task.
double get_start_time() const
Returns the time at which the task was started, according to the task manager's clock.
void set_delay(double delay)
Specifies the amount of time, in seconds, by which this task will be delayed after it has been added ...
int get_start_frame() const
Returns the frame number at which the task was started, according to the task manager's clock.
double get_delay() const
Returns the delay value that has been set via set_delay, if any.
set_priority
Specifies a priority value for this task.
std::string get_name_prefix() const
Returns the initial part of the name, up to but not including any trailing digits following a hyphen ...
get_manager
Returns the AsyncTaskManager that this task is active on.
void recalc_wake_time()
If the task is currently sleeping on a task chain, this resets its wake time to the current time + ge...
set_sort
Specifies a sort value for this task.
void clear_name()
Resets the Namable's name to empty.
void output(std::ostream &out) const
Outputs the Namable.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...