From 4d1e6868cd2ee4c39b7efb4527e39dd7e037abdb Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 25 Mar 2005 08:20:18 +0000 Subject: [PATCH] Introduce updateSnooze that continously increases type check interval from 1 to 5 seconds as the app remains unchanged. --- src/helma/scripting/rhino/RhinoCore.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java index be3c4089..8e6c0848 100644 --- a/src/helma/scripting/rhino/RhinoCore.java +++ b/src/helma/scripting/rhino/RhinoCore.java @@ -67,6 +67,10 @@ public final class RhinoCore implements ScopeProvider { HelmaDebugger debugger = null; + // dynamic portion of the type check sleep that grows + // as the app remains unchanged + long updateSnooze = 500; + /** * Create a Rhino evaluator for the given application and request evaluator. */ @@ -311,12 +315,12 @@ public final class RhinoCore implements ScopeProvider { * before. Others will be updated/compiled on demand. */ public void updatePrototypes() throws IOException { - if ((System.currentTimeMillis() - lastUpdate) < 1000L) { + if ((System.currentTimeMillis() - lastUpdate) < 1000L + updateSnooze) { return; } synchronized(this) { - if ((System.currentTimeMillis() - lastUpdate) < 1000L) { + if ((System.currentTimeMillis() - lastUpdate) < 1000L + updateSnooze) { return; } @@ -358,6 +362,9 @@ public final class RhinoCore implements ScopeProvider { } lastUpdate = System.currentTimeMillis(); + // max updateSnooze is 4 seconds, reached after 66.6 idle minutes + long newSnooze = (lastUpdate - app.typemgr.getLastCodeUpdate()) / 1000; + updateSnooze = Math.min(4000, Math.max(0, newSnooze)); } }