mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-27 10:56: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
|
||||
},
|
||||
{//instance
|
||||
init: function () {
|
||||
this.is_running = false;
|
||||
this.is_stopping = false;
|
||||
init: function (interval) {
|
||||
this._is_running = false;
|
||||
this._is_stopping = false;
|
||||
this._interval_id = null;
|
||||
this._interval = interval ? interval : 1000;
|
||||
},
|
||||
_run: function () {
|
||||
console.log("[thread] tick");
|
||||
|
@ -190,20 +191,20 @@ $.Class("Thread",
|
|||
var _this = this;
|
||||
console.log("[thread] starting")
|
||||
var wrapper = function () {
|
||||
if (_this.is_running && _this.is_stopping) {
|
||||
if (_this._is_running && _this._is_stopping) {
|
||||
console.log("[thread] shutting down")
|
||||
clearInterval(_this._interval_id);
|
||||
_this.is_running = false;
|
||||
_this._is_running = false;
|
||||
return;
|
||||
}
|
||||
_this._run.apply(_this);
|
||||
};
|
||||
this._interval_id = setInterval(wrapper, 1000);
|
||||
this.is_running = true;
|
||||
this._interval_id = setInterval(wrapper, this._interval);
|
||||
this._is_running = true;
|
||||
},
|
||||
// stop the run loop
|
||||
stop: function () {
|
||||
this.is_stopping = true;
|
||||
this._is_stopping = true;
|
||||
console.log("[thread] request stop")
|
||||
// TODO: consider finding a way to make this block
|
||||
// or alternatively, having a callback which is called
|
||||
|
@ -228,7 +229,7 @@ Thread("ChangesetLoader",
|
|||
},
|
||||
{//instance
|
||||
init: function () {
|
||||
this._super();
|
||||
this._super(100);
|
||||
this.queue_large = [];
|
||||
this.queue_medium = [];
|
||||
this.queue_small = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue