This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 977692 - [Clock] Refactor Ring View r=millermedeiros
- Loading branch information
Showing
71 changed files
with
1,798 additions
and
3,392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
define(function(require) { | ||
|
||
/** | ||
* A serial queue of functions. Call `.push()` to add a function to | ||
* the task; when each function completes (as a result of calling | ||
* 'done()'), the next item in the queue will be executed. | ||
*/ | ||
function AsyncQueue() { | ||
this.queue = []; | ||
this.current = null; | ||
} | ||
|
||
AsyncQueue.prototype = { | ||
/** | ||
* Add a function to the execution queue. It should accept one | ||
* argument, a 'done' callback. | ||
*/ | ||
push: function(fn) { | ||
if (!this.current) { | ||
this._startTask(fn); | ||
} else { | ||
this.queue.push(fn); | ||
} | ||
}, | ||
|
||
_startTask: function(fn) { | ||
this.current = fn; | ||
fn(this._nextTask.bind(this)); | ||
}, | ||
|
||
_nextTask: function() { | ||
this.current = null; | ||
if (this.queue.length) { | ||
this._startTask(this.queue.shift()); | ||
} | ||
} | ||
}; | ||
|
||
return AsyncQueue; | ||
}); | ||
|
Oops, something went wrong.