Browse Source

add async-load-delay

David Rose 17 years ago
parent
commit
09dc4e3b84

+ 10 - 0
panda/src/pgraph/config_pgraph.cxx

@@ -274,6 +274,16 @@ ConfigVariableBool flatten_geoms
           "only the NodePath interfaces; you may still make the lower-level "
           "SceneGraphReducer calls directly."));
 
+ConfigVariableDouble async_load_delay
+("async-load-delay", 0.0,
+PRC_DESC("If this is nonzero, it represents an artificial delay, "
+         "in seconds, that is imposed on every asynchronous load attempt "
+         "(within the thread).  Its purpose is to help debug errors that "
+         "may occur when an asynchronous load is delayed.  The "
+         "delay is per-model, and all aync loads will be queued "
+         "up behind the delay--it is as if the time it takes to read a "
+         "file is increased by this amount per read."));
+
 ConfigVariableBool polylight_info
 ("polylight-info", false,
  PRC_DESC("Set this true to view some info statements regarding the polylight. "

+ 1 - 0
panda/src/pgraph/config_pgraph.h

@@ -53,6 +53,7 @@ extern ConfigVariableInt max_collect_indices;
 extern ConfigVariableBool premunge_data;
 extern ConfigVariableBool preserve_geom_nodes;
 extern ConfigVariableBool flatten_geoms;
+extern ConfigVariableDouble async_load_delay;
 
 extern ConfigVariableBool polylight_info;
 extern ConfigVariableDouble lod_fade_time;

+ 6 - 0
panda/src/pgraph/modelLoadRequest.cxx

@@ -14,6 +14,7 @@
 
 #include "modelLoadRequest.h"
 #include "loader.h"
+#include "config_pgraph.h"
 
 TypeHandle ModelLoadRequest::_type_handle;
 
@@ -24,6 +25,11 @@ TypeHandle ModelLoadRequest::_type_handle;
 ////////////////////////////////////////////////////////////////////
 bool ModelLoadRequest::
 do_task() {
+  double delay = async_load_delay;
+  if (delay != 0.0) {
+    Thread::sleep(delay);
+  }
+
   Loader *loader;
   DCAST_INTO_R(loader, _manager, false);