|
|
|
@ -31,10 +31,10 @@ class Waterfall { |
|
|
|
|
class Executor { |
|
|
|
|
constructor () { |
|
|
|
|
this.ready = false |
|
|
|
|
this._mainWaterfallObject = new Waterfall() |
|
|
|
|
this._bufferWaterfallObject = new Waterfall() |
|
|
|
|
this._bufferWaterfallObject.chain(new Promise(resolve => { |
|
|
|
|
this._resolveBuffer = resolve |
|
|
|
|
this.queue = new Waterfall() |
|
|
|
|
this.buffer = new Waterfall() |
|
|
|
|
this.buffer.chain(new Promise(resolve => { |
|
|
|
|
this.triggerBuffer = resolve |
|
|
|
|
})) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -77,8 +77,8 @@ class Executor { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pushAsync (task, forceQueuing) { |
|
|
|
|
if (this.ready || forceQueuing) return this._mainWaterfallObject.waterfall(task)() |
|
|
|
|
else return this._bufferWaterfallObject.waterfall(task)() |
|
|
|
|
if (this.ready || forceQueuing) return this.queue.waterfall(task)() |
|
|
|
|
else return this.buffer.waterfall(task)() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -87,8 +87,8 @@ class Executor { |
|
|
|
|
*/ |
|
|
|
|
processBuffer () { |
|
|
|
|
this.ready = true |
|
|
|
|
this._resolveBuffer() |
|
|
|
|
this._mainWaterfallObject.waterfall(() => this._bufferWaterfallObject.guardian) |
|
|
|
|
this.triggerBuffer() |
|
|
|
|
this.queue.waterfall(() => this.buffer.guardian) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|