diff --git a/jsdoc.js b/jsdoc.js index 2005d9e9..42f81586 100644 --- a/jsdoc.js +++ b/jsdoc.js @@ -1,4 +1,4 @@ -/*global app: true, args: true, env: true, Packages: true, publish: true */ +/*global __timerPool: true, app: true, args: true, env: true, Packages: true, publish: true */ /** * @project jsdoc * @author Michael Mathews @@ -433,5 +433,8 @@ catch(e) { } finally { env.run.finish = new Date(); - process.exit(0); + // on Rhino, we never exit unless we shut down the timer pool + if (__timerPool) { + __timerPool.shutdownNow(); + } } diff --git a/lib/rhino-shim.js b/lib/rhino-shim.js index b7dfb685..3a622b0c 100644 --- a/lib/rhino-shim.js +++ b/lib/rhino-shim.js @@ -16,6 +16,8 @@ __dirname = env.dirname; * @see https://developer.mozilla.org/en-US/docs/DOM/window#Methods */ +__timerPool = null; + setTimeout = null, clearTimeout = null, setInterval = null, @@ -23,7 +25,7 @@ clearInterval = null; (function() { // TODO: tune number of threads if necessary - var timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(10); + __timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(10); var timers = {}; var timerCount = 1; var timerUnits = java.util.concurrent.TimeUnit.MILLISECONDS; @@ -37,13 +39,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]; } }; @@ -51,7 +53,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; };