(function(define) { 'use strict';
define(function(require) {
var Queue = require('./Queue');
function Scheduler(enqueue) {
this._handlerQueue = new Queue(15);
this._afterQueue = new Queue(5);
this.drain = function() {
Scheduler.prototype.enqueue = function(task) {
this._handlerQueue.push(task);
this._enqueue(this.drain);
Scheduler.prototype.afterQueue = function(f, x, y) {
this._afterQueue.push(f);
this._afterQueue.push(x);
this._afterQueue.push(y);
this._enqueue(this.drain);
Scheduler.prototype._drain = function() {
var q = this._handlerQueue;
q.shift()(q.shift(), q.shift());
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));