author | Kris Maglione <maglione.k@gmail.com> |
Sun, 10 Sep 2017 13:14:12 -0700 | |
changeset 380223 | 8154fcbcb707191b3526ff10d78a1ea36550213b |
parent 380222 | deef51eb0b7e0b528935f8be1ce8f36912464a1c |
child 380224 | df31bae194f894d29e0f91ef79d0aa34709eafb1 |
push id | 32482 |
push user | archaeopteryx@coole-files.de |
push date | Tue, 12 Sep 2017 09:35:40 +0000 |
treeherder | mozilla-central@b0e945eed81d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | florian |
bugs | 1391707 |
milestone | 57.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/modules/DeferredTask.jsm +++ b/toolkit/modules/DeferredTask.jsm @@ -85,41 +85,43 @@ this.EXPORTED_SYMBOLS = [ // Globals const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils", "resource://gre/modules/PromiseUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Task", - "resource://gre/modules/Task.jsm"); const Timer = Components.Constructor("@mozilla.org/timer;1", "nsITimer", "initWithCallback"); // DeferredTask /** * Sets up a task whose execution can be triggered after a delay. * * @param aTaskFn - * Function or generator function to execute. This argument is passed to - * the "Task.spawn" method every time the task should be executed. This + * Function to execute. If the function returns a promise, the task is + * not considered complete until that promise resolves. This * task is never re-entered while running. * @param aDelayMs * Time between executions, in milliseconds. Multiple attempts to run * the task before the delay has passed are coalesced. This time of * inactivity is guaranteed to pass between multiple executions of the * task, except on finalization, when the task may restart immediately * after the previous execution finished. */ this.DeferredTask = function(aTaskFn, aDelayMs) { this._taskFn = aTaskFn; this._delayMs = aDelayMs; + + if (aTaskFn.isGenerator()) { + Cu.reportError(new Error("Unexpected generator function passed to DeferredTask")); + } } this.DeferredTask.prototype = { /** * Function or generator function to execute. */ _taskFn: null, @@ -296,19 +298,14 @@ this.DeferredTask.prototype = { })().catch(Cu.reportError)); }, /** * Executes the associated task and catches exceptions. */ async _runTask() { try { - let result = this._taskFn(); - if (Object.prototype.toString.call(result) == "[object Generator]") { - await Task.spawn(result); // eslint-disable-line mozilla/no-task - } else { - await result; - } + await this._taskFn(); } catch (ex) { Cu.reportError(ex); } }, };