Skip to content

Commit

Permalink
provide API for setting worker timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Mar 13, 2015
1 parent 101656e commit 7cefaf3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/ace/edit_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,16 @@ var EditSession = function(text, mode) {
**/
this.getUseWorker = function() { return this.$useWorker; };

/**
* Sets the idle time (in milliseconds) before diagnostics are shown.
* No-op if no worker is currently attached.
* @param {Numeric} Delay in milliseconds.
*/
this.setWorkerTimeout = function(delayMs) {
if (this.$worker)
this.$worker.setTimeout(delayMs);
};

/**
* Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event.
**/
Expand Down
12 changes: 9 additions & 3 deletions lib/ace/worker/mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ var Mirror = exports.Mirror = function(sender) {
var _self = this;
sender.on("change", function(e) {
doc.applyDeltas(e.data);
if (_self.$timeout)
return deferredUpdate.schedule(_self.$timeout);
_self.onUpdate();
if (_self.$timeout) {
deferredUpdate.cancel();
deferredUpdate.schedule(_self.$timeout);
} else {
_self.onUpdate();
}
});
sender.on("setTimeout", function(e) {
_self.setTimeout(e.data);
});
};

Expand Down
4 changes: 4 additions & 0 deletions lib/ace/worker/worker_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
}
};

this.setTimeout = function(delayMs) {
this.emit("setTimeout", {data: delayMs});
};

this.attachToDocument = function(doc) {
if(this.$doc)
this.terminate();
Expand Down

0 comments on commit 7cefaf3

Please sign in to comment.