14 #ifndef ASYNCTASKCHAIN_H 15 #define ASYNCTASKCHAIN_H 56 void set_tick_clock(
bool tick_clock);
57 bool get_tick_clock()
const;
59 BLOCKING
void set_num_threads(
int num_threads);
60 int get_num_threads()
const;
61 int get_num_running_threads()
const;
63 BLOCKING
void set_thread_priority(ThreadPriority priority);
64 ThreadPriority get_thread_priority()
const;
66 void set_frame_budget(
double frame_budget);
67 double get_frame_budget()
const;
69 void set_frame_sync(
bool frame_sync);
70 bool get_frame_sync()
const;
72 void set_timeslice_priority(
bool timeslice_priority);
73 bool get_timeslice_priority()
const;
75 BLOCKING
void stop_threads();
77 INLINE
bool is_started()
const;
81 BLOCKING
void wait_for_tasks();
83 int get_num_tasks()
const;
89 double get_next_wake_time()
const;
91 virtual void output(std::ostream &out)
const;
92 virtual void write(std::ostream &out,
int indent_level = 0)
const;
95 class AsyncTaskChainThread;
99 bool do_remove(
AsyncTask *task,
bool upon_death=
false);
100 void do_wait_for_tasks();
106 void service_one_task(AsyncTaskChainThread *thread);
107 void cleanup_task(
AsyncTask *task,
bool upon_death,
bool clean_exit);
108 bool finish_sort_group();
109 void filter_timeslice_priority();
110 void do_stop_threads();
111 void do_start_threads();
115 void cleanup_pickup_mode();
116 INLINE
double do_get_next_wake_time()
const;
117 static INLINE
double get_wake_time(
AsyncTask *task);
118 void do_output(std::ostream &out)
const;
119 void do_write(std::ostream &out,
int indent_level)
const;
121 void write_task_line(std::ostream &out,
int indent_level,
AsyncTask *task,
double now)
const;
124 class AsyncTaskChainThread :
public Thread {
126 AsyncTaskChainThread(
const std::string &name,
AsyncTaskChain *chain);
127 virtual void thread_main();
133 class AsyncTaskSortWakeTime {
136 return AsyncTaskChain::get_wake_time(a) > AsyncTaskChain::get_wake_time(b);
140 class AsyncTaskSortPriority {
154 return a->_implicit_sort > b->_implicit_sort;
172 bool _timeslice_priority;
174 ThreadPriority _thread_priority;
176 double _frame_budget;
178 int _num_busy_threads;
180 int _num_awaiting_tasks;
191 double _time_in_frame;
192 bool _block_till_next_frame;
194 unsigned int _next_implicit_sort;
203 static void init_type() {
204 TypedReferenceCount::init_type();
206 TypedReferenceCount::get_class_type());
209 return get_class_type();
211 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
217 friend class AsyncTaskChainThread;
220 friend class AsyncTaskSortWakeTime;
223 INLINE std::ostream &operator << (std::ostream &out,
const AsyncTaskChain &chain) {
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
get_sort
Returns the task's current sort value.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
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 base class for all things which can have a name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The AsyncTaskChain is a subset of the AsyncTaskManager.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
double get_start_time() const
Returns the time at which the task was started, according to the task manager's clock.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a concrete task performed by an AsyncManager.
This class implements a condition variable; see ConditionVar for a brief introduction to this class.
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_priority
Returns the task's current priority value.