Browse Source

combine DS_again with DS_restart

David Rose 17 years ago
parent
commit
a74bf92e67

+ 1 - 3
direct/src/task/TaskNew.py

@@ -3,7 +3,7 @@ AsyncTaskManager interface.  It replaces the old full-Python
 implementation of the Task system. """
 
 __all__ = ['Task', 'TaskManager',
-           'cont', 'done', 'again', 'pickup', 'restart']
+           'cont', 'done', 'again', 'pickup']
 
 from direct.directnotify.DirectNotifyGlobal import *
 from direct.showbase import ExceptionVarDump
@@ -57,7 +57,6 @@ done = AsyncTask.DSDone
 cont = AsyncTask.DSCont
 again = AsyncTask.DSAgain
 pickup = AsyncTask.DSPickup
-restart = AsyncTask.DSRestart
 
 # Alias PythonTask to Task for historical purposes.
 Task = PythonTask
@@ -69,7 +68,6 @@ Task.DtoolClassDict['done'] = done
 Task.DtoolClassDict['cont'] = cont
 Task.DtoolClassDict['again'] = again
 Task.DtoolClassDict['pickup'] = pickup
-Task.DtoolClassDict['restart'] = restart
 
 class TaskManager:
     notify = directNotify.newCategory("TaskManager")

+ 8 - 9
panda/src/event/asyncTask.cxx

@@ -376,21 +376,20 @@ is_runnable() {
 //               DS_cont: the task has more work to do, keep it active
 //               and call this function again in the next epoch.
 //
-//               DS_again: put the task to sleep for get_delay()
-//               seconds, then put it back on the active queue.
+//               DS_again: like DS_cont, but next time call the
+//               function from the beginning, almost as if it were
+//               freshly added to the task manager.  The task's
+//               get_start_time() will be reset to now, and its
+//               get_elapsed_time() will be reset to 0.  If the task
+//               has a set_delay(), it will wait again for that amount
+//               of time to elapse before restarting.  Timing
+//               accounting, however, is not reset.
 //
 //               DS_pickup: like DS_cont, but if the task chain has a
 //               frame budget and that budget has not yet been met,
 //               re-run the task again without waiting for the next
 //               frame.  Otherwise, run it next epoch as usual.
 //
-//               DS_restart: like DS_cont, but next time call the
-//               function from the beginning, almost as if it were
-//               freshly added to the task manager.  The task's
-//               get_start_time() will be reset to now, and its
-//               get_elapsed_time() will be reset to 0.  Timing
-//               accounting, however, is not reset.
-//
 //               DS_abort: abort the task, and interrupt the whole
 //               AsyncTaskManager.
 //

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

@@ -51,9 +51,8 @@ PUBLISHED:
   enum DoneStatus {
     DS_done,    // normal task completion
     DS_cont,    // run task again next epoch
-    DS_again,   // run task again after at least get_delay() seconds
+    DS_again,   // start the task over from the beginning
     DS_pickup,  // run task again this frame, if frame budget allows
-    DS_restart, // start the task over from the beginning
     DS_abort,   // abort the task and interrupt the whole task manager
   };
 

+ 1 - 4
panda/src/event/asyncTaskChain.cxx

@@ -716,10 +716,6 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) {
 
       } else {
         switch (ds) {
-        case AsyncTask::DS_restart:
-          task->_start_time = _manager->_clock->get_frame_time();
-          // Fall through.
-
         case AsyncTask::DS_cont:
           // The task is still alive; put it on the next frame's active
           // queue.
@@ -733,6 +729,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) {
           {
             double now = _manager->_clock->get_frame_time();
             task->_wake_time = now + task->get_delay();
+            task->_start_time = task->_wake_time;
             task->_state = AsyncTask::S_sleeping;
             _sleeping.push_back(task);
             push_heap(_sleeping.begin(), _sleeping.end(), AsyncTaskSortWakeTime());

+ 1 - 2
panda/src/event/pythonTask.cxx

@@ -409,14 +409,13 @@ do_python_task() {
   if (PyInt_Check(result)) {
     int retval = PyInt_AS_LONG(result);
     switch (retval) {
-    case DS_restart:
+    case DS_again:
       Py_XDECREF(_generator);
       _generator = NULL;
       // Fall through.
 
     case DS_done:
     case DS_cont:
-    case DS_again:
     case DS_pickup:
       // Legitimate value.
       Py_DECREF(result);