15 #ifndef ASYNCTASKCHAIN_H 16 #define ASYNCTASKCHAIN_H 18 #include "pandabase.h" 20 #include "asyncTask.h" 21 #include "asyncTaskCollection.h" 22 #include "typedReferenceCount.h" 24 #include "conditionVarFull.h" 27 #include "pStatCollector.h" 28 #include "clockObject.h" 63 void set_tick_clock(
bool tick_clock);
64 bool get_tick_clock()
const;
66 BLOCKING
void set_num_threads(
int num_threads);
67 int get_num_threads()
const;
68 int get_num_running_threads()
const;
70 BLOCKING
void set_thread_priority(ThreadPriority priority);
71 ThreadPriority get_thread_priority()
const;
73 void set_frame_budget(
double frame_budget);
74 double get_frame_budget()
const;
76 void set_frame_sync(
bool frame_sync);
77 bool get_frame_sync()
const;
79 void set_timeslice_priority(
bool timeslice_priority);
80 bool get_timeslice_priority()
const;
82 BLOCKING
void stop_threads();
84 INLINE
bool is_started()
const;
88 BLOCKING
void wait_for_tasks();
90 int get_num_tasks()
const;
96 double get_next_wake_time()
const;
98 virtual void output(ostream &out)
const;
99 virtual void write(ostream &out,
int indent_level = 0)
const;
102 class AsyncTaskChainThread;
107 void do_wait_for_tasks();
111 int find_task_on_heap(
const TaskHeap &heap,
AsyncTask *task)
const;
113 void service_one_task(AsyncTaskChainThread *thread);
114 void cleanup_task(
AsyncTask *task,
bool upon_death,
bool clean_exit);
115 bool finish_sort_group();
116 void filter_timeslice_priority();
117 void do_stop_threads();
118 void do_start_threads();
122 void cleanup_pickup_mode();
123 INLINE
double do_get_next_wake_time()
const;
124 static INLINE
double get_wake_time(
AsyncTask *task);
125 void do_output(ostream &out)
const;
126 void do_write(ostream &out,
int indent_level)
const;
128 void write_task_line(ostream &out,
int indent_level,
AsyncTask *task,
double now)
const;
131 class AsyncTaskChainThread :
public Thread {
134 virtual void thread_main();
140 class AsyncTaskSortWakeTime {
143 return AsyncTaskChain::get_wake_time(a) > AsyncTaskChain::get_wake_time(b);
147 class AsyncTaskSortPriority {
174 bool _timeslice_priority;
176 ThreadPriority _thread_priority;
178 double _frame_budget;
180 int _num_busy_threads;
183 TaskHeap _this_active;
184 TaskHeap _next_active;
192 double _time_in_frame;
193 bool _block_till_next_frame;
202 static void init_type() {
203 TypedReferenceCount::init_type();
204 register_type(_type_handle,
"AsyncTaskChain",
205 TypedReferenceCount::get_class_type());
208 return get_class_type();
210 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
215 friend class AsyncTaskChainThread;
218 friend class AsyncTaskSortWakeTime;
221 INLINE ostream &operator << (ostream &out,
const AsyncTaskChain &chain) {
226 #include "asyncTaskChain.I" void output(ostream &out) const
Outputs the Namable.
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
int get_priority() const
Returns the task's current priority value.
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.
int get_sort() const
Returns the task's current sort value.
The AsyncTaskChain is a subset of the AsyncTaskManager.
double get_start_time() const
Returns the time at which the task was started, according to the task manager's clock.
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.
TypeHandle is the identifier used to differentiate C++ class types.