David Rose 17 anni fa
parent
commit
8e68eb1dcd
2 ha cambiato i file con 26 aggiunte e 0 eliminazioni
  1. 25 0
      panda/src/event/asyncTask.I
  2. 1 0
      panda/src/event/asyncTask.h

+ 25 - 0
panda/src/event/asyncTask.I

@@ -23,6 +23,31 @@ get_state() const {
   return _state;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: AsyncTask::is_alive
+//       Access: Published
+//  Description: Returns true if the task is currently active or
+//               sleeping on some task chain, meaning that it will be
+//               executed in its turn, or false if it is not active.
+//               If the task has recently been removed while it is in
+//               the middle of execution, this will return false,
+//               because the task will not run again once it finishes.
+////////////////////////////////////////////////////////////////////
+INLINE bool AsyncTask::
+is_alive() const {
+  switch (_state) {
+  case S_active:
+  case S_servicing:
+  case S_sleeping:
+  case S_active_nested:
+    return true;
+
+  case S_inactive:
+  case S_servicing_removed:
+    return false;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: AsyncTask::get_manager
 //       Access: Published

+ 1 - 0
panda/src/event/asyncTask.h

@@ -69,6 +69,7 @@ PUBLISHED:
   };
 
   INLINE State get_state() const;
+  INLINE bool is_alive() const;
   INLINE AsyncTaskManager *get_manager() const;
 
   void remove();