mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
allow shutdown to happen without swallowing exceptions (#257)
This commit is contained in:
parent
13274551c5
commit
1a7a7f8588
7
jsdoc.js
7
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 <micmath@gmail.com>
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user