21 AsyncTaskCollection() {
36 void AsyncTaskCollection::
49 nassertv(task !=
nullptr);
51 if (_tasks.get_ref_count() > 1) {
52 AsyncTasks old_tasks = _tasks;
53 _tasks = AsyncTasks::empty_array(0);
54 _tasks.v() = old_tasks.v();
57 _tasks.push_back(task);
66 size_t task_index = (size_t)-1;
67 for (
size_t i = 0; i < _tasks.size(); ++i) {
68 if (_tasks[i] == task) {
74 if (task_index == (
size_t)-1) {
83 if (_tasks.get_ref_count() > 1) {
84 AsyncTasks old_tasks = _tasks;
85 _tasks = AsyncTasks::empty_array(0);
86 _tasks.v() = old_tasks.v();
89 _tasks.erase(_tasks.begin() + task_index);
101 for (
int i = 0; i < other_num_tasks; i++) {
113 AsyncTasks new_tasks;
115 for (
int i = 0; i < num_tasks; i++) {
118 new_tasks.push_back(task);
131 AsyncTasks new_tasks;
134 for (
size_t i = 0; i < num_tasks; i++) {
136 bool duplicated =
false;
138 for (
size_t j = 0; j < i && !duplicated; j++) {
143 new_tasks.push_back(task);
179 for (
size_t i = 0; i < num_tasks; ++i) {
181 if (task->get_name() == name) {
191 size_t AsyncTaskCollection::
192 get_num_tasks()
const {
193 return _tasks.size();
201 nassertr(index < _tasks.size(),
nullptr);
203 return _tasks[index];
215 if (_tasks.get_ref_count() > 1) {
216 AsyncTasks old_tasks = _tasks;
217 _tasks = AsyncTasks::empty_array(0);
218 _tasks.v() = old_tasks.v();
221 nassertv(index < _tasks.size());
222 _tasks.erase(_tasks.begin() + index);
231 nassertr(index < _tasks.size(),
nullptr);
232 return _tasks[index];
241 return _tasks.size();
251 out <<
"1 AsyncTask";
262 write(std::ostream &out,
int indent_level)
const {
get_task
Returns the nth AsyncTask in the collection.
void clear()
Removes all AsyncTasks from the collection.
void add_task(AsyncTask *task)
Adds a new AsyncTask to the collection.
A list of tasks, for instance as returned by some of the AsyncTaskManager query functions.
bool has_task(AsyncTask *task) const
Returns true if the indicated AsyncTask appears in this collection, false otherwise.
void output(std::ostream &out) const
Writes a brief one-line description of the AsyncTaskCollection to the indicated output stream.
AsyncTask * operator [](size_t index) const
Returns the nth AsyncTask in the collection.
AsyncTask * find_task(const std::string &name) const
Returns the task in the collection with the indicated name, if any, or NULL if no task has that name.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void add_tasks_from(const AsyncTaskCollection &other)
Adds all the AsyncTasks indicated in the other collection to this task.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void remove_tasks_from(const AsyncTaskCollection &other)
Removes from this collection all of the AsyncTasks listed in the other collection.
void remove_duplicate_tasks()
Removes any duplicate entries of the same AsyncTasks on this collection.
This class represents a concrete task performed by an AsyncManager.
bool remove_task(AsyncTask *task)
Removes the indicated AsyncTask from the collection.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the AsyncTaskCollection to the indicated output stream.
size_t size() const
Returns the number of tasks in the collection.
get_num_tasks
Returns the number of AsyncTasks in the collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.