Icinga.Timer: use setTimeout() instead of setInterval()

refs #11693
This commit is contained in:
Alexander A. Klimov 2017-02-10 10:14:14 +01:00
parent 80d3abed9d
commit cb2093513a

View File

@ -41,6 +41,8 @@
this.lastRuntime = []; this.lastRuntime = [];
this.isRunning = false;
}; };
Icinga.Timer.prototype = { Icinga.Timer.prototype = {
@ -49,8 +51,16 @@
* The initialization function starts our ticker * The initialization function starts our ticker
*/ */
initialize: function () { initialize: function () {
this.isRunning = true;
var _this = this; var _this = this;
this.ticker = setInterval(function () { _this.tick(); }, this.interval); var f = function () {
if (_this.isRunning) {
_this.tick();
setTimeout(f, _this.interval);
}
};
f();
}, },
/** /**
@ -112,10 +122,7 @@
* Our destroy function will clean up everything. Unused right now. * Our destroy function will clean up everything. Unused right now.
*/ */
destroy: function () { destroy: function () {
this.isRunning = false;
if (this.ticker !== null) {
clearInterval(this.ticker);
}
this.icinga = null; this.icinga = null;
$.each(this.observers, function (idx, observer) { $.each(this.observers, function (idx, observer) {