From ef6d78f88e7b86c40b6e11638daf953aad372e06 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 11 Nov 2012 02:48:30 -0800 Subject: [PATCH] simpler solution to #257 keeping env.run.finish in case we add more logging at some point --- jsdoc.js | 20 +++++++++----------- lib/rhino-shim.js | 10 ++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/jsdoc.js b/jsdoc.js index 42f815869..65acca92e 100644 --- a/jsdoc.js +++ b/jsdoc.js @@ -423,18 +423,16 @@ function main() { } } -try { main(); } -catch(e) { - if (e.rhinoException != null) { - e.rhinoException.printStackTrace(); - } else { - throw e; - } +try { + main(); + env.run.finish = new Date(); + process.exit(0); } -finally { +catch(e) { env.run.finish = new Date(); - // on Rhino, we never exit unless we shut down the timer pool - if (__timerPool) { - __timerPool.shutdownNow(); + if (e.rhinoException != null) { + e.rhinoException.printStackTrace(); + } else { + throw e; } } diff --git a/lib/rhino-shim.js b/lib/rhino-shim.js index 3a622b0c9..b7dfb6855 100644 --- a/lib/rhino-shim.js +++ b/lib/rhino-shim.js @@ -16,8 +16,6 @@ __dirname = env.dirname; * @see https://developer.mozilla.org/en-US/docs/DOM/window#Methods */ -__timerPool = null; - setTimeout = null, clearTimeout = null, setInterval = null, @@ -25,7 +23,7 @@ clearInterval = null; (function() { // TODO: tune number of threads if necessary - __timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(10); + var timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(10); var timers = {}; var timerCount = 1; var timerUnits = java.util.concurrent.TimeUnit.MILLISECONDS; @@ -39,13 +37,13 @@ clearInterval = null; setTimeout = function(fn, delay) { var timerId = timerCount++; var callback = getCallback(fn); - timers[timerId] = __timerPool.schedule(callback, delay, timerUnits); + timers[timerId] = timerPool.schedule(callback, delay, timerUnits); return timerId; }; clearTimeout = function(timerId) { if (timers[timerId]) { - __timerPool.remove(timers[timerId]); + timerPool.remove(timers[timerId]); delete timers[timerId]; } }; @@ -53,7 +51,7 @@ clearInterval = null; setInterval = function(fn, delay) { var timerId = timerCount++; var callback = getCallback(fn); - timers[timerId] = __timerPool.scheduleAtFixedRate(callback, delay, delay, timerUnits); + timers[timerId] = timerPool.scheduleAtFixedRate(callback, delay, delay, timerUnits); return timerId; };