mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
Add configurable interval
This commit is contained in:
parent
30279e2fe3
commit
47a6c74bde
1 changed files with 10 additions and 9 deletions
|
@ -177,10 +177,11 @@ $.Class("Thread",
|
||||||
{//statics
|
{//statics
|
||||||
},
|
},
|
||||||
{//instance
|
{//instance
|
||||||
init: function () {
|
init: function (interval) {
|
||||||
this.is_running = false;
|
this._is_running = false;
|
||||||
this.is_stopping = false;
|
this._is_stopping = false;
|
||||||
this._interval_id = null;
|
this._interval_id = null;
|
||||||
|
this._interval = interval ? interval : 1000;
|
||||||
},
|
},
|
||||||
_run: function () {
|
_run: function () {
|
||||||
console.log("[thread] tick");
|
console.log("[thread] tick");
|
||||||
|
@ -190,20 +191,20 @@ $.Class("Thread",
|
||||||
var _this = this;
|
var _this = this;
|
||||||
console.log("[thread] starting")
|
console.log("[thread] starting")
|
||||||
var wrapper = function () {
|
var wrapper = function () {
|
||||||
if (_this.is_running && _this.is_stopping) {
|
if (_this._is_running && _this._is_stopping) {
|
||||||
console.log("[thread] shutting down")
|
console.log("[thread] shutting down")
|
||||||
clearInterval(_this._interval_id);
|
clearInterval(_this._interval_id);
|
||||||
_this.is_running = false;
|
_this._is_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_this._run.apply(_this);
|
_this._run.apply(_this);
|
||||||
};
|
};
|
||||||
this._interval_id = setInterval(wrapper, 1000);
|
this._interval_id = setInterval(wrapper, this._interval);
|
||||||
this.is_running = true;
|
this._is_running = true;
|
||||||
},
|
},
|
||||||
// stop the run loop
|
// stop the run loop
|
||||||
stop: function () {
|
stop: function () {
|
||||||
this.is_stopping = true;
|
this._is_stopping = true;
|
||||||
console.log("[thread] request stop")
|
console.log("[thread] request stop")
|
||||||
// TODO: consider finding a way to make this block
|
// TODO: consider finding a way to make this block
|
||||||
// or alternatively, having a callback which is called
|
// or alternatively, having a callback which is called
|
||||||
|
@ -228,7 +229,7 @@ Thread("ChangesetLoader",
|
||||||
},
|
},
|
||||||
{//instance
|
{//instance
|
||||||
init: function () {
|
init: function () {
|
||||||
this._super();
|
this._super(100);
|
||||||
this.queue_large = [];
|
this.queue_large = [];
|
||||||
this.queue_medium = [];
|
this.queue_medium = [];
|
||||||
this.queue_small = [];
|
this.queue_small = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue