Panda3D
asyncTaskManager.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file asyncTaskManager.I
10  * @author drose
11  * @date 2006-08-23
12  */
13 
14 /**
15  * Replaces the clock pointer used within the AsyncTaskManager. This is used
16  * to control when tasks with a set_delay() specified will be scheduled. It
17  * can also be ticked automatically each epoch, if set_tick_clock() is true.
18  *
19  * The default is the global clock pointer.
20  */
21 INLINE void AsyncTaskManager::
22 set_clock(ClockObject *clock) {
23  _clock = clock;
24 }
25 
26 /**
27  * Returns the clock pointer used within the AsyncTaskManager. See
28  * set_clock().
29  */
30 INLINE ClockObject *AsyncTaskManager::
31 get_clock() {
32  return _clock;
33 }
34 
35 /**
36  * Returns the number of tasks that are currently active or sleeping within
37  * the task manager.
38  */
39 INLINE size_t AsyncTaskManager::
40 get_num_tasks() const {
41  MutexHolder holder(_lock);
42  return _num_tasks;
43 }
44 
45 /**
46  * Returns a pointer to the global AsyncTaskManager. This is the
47  * AsyncTaskManager that most code should use for queueing tasks and suchlike.
48  */
51  if (_global_ptr == nullptr) {
52  make_global_ptr();
53  }
54  return _global_ptr;
55 }
56 
57 /**
58  * Adds the task to the _tasks_by_name index, if it has a nonempty name.
59  */
60 INLINE void AsyncTaskManager::
61 add_task_by_name(AsyncTask *task) {
62  if (!task->get_name().empty()) {
63  _tasks_by_name.insert(task);
64  }
65 }
A class to manage a loose queue of isolated tasks, which can be performed either synchronously (in th...
size_t get_num_tasks() const
Returns the number of tasks that are currently active or sleeping within the task manager.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
Definition: mutexHolder.h:25
set_clock
Replaces the clock pointer used within the AsyncTaskManager.
A ClockObject keeps track of elapsed real time and discrete time.
Definition: clockObject.h:58
This class represents a concrete task performed by an AsyncManager.
Definition: asyncTask.h:32
static AsyncTaskManager * get_global_ptr()
Returns a pointer to the global AsyncTaskManager.