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