pull/11/head
Timothée Rebours 3 years ago
parent 06dc91915c
commit 8cadb9128e
  1. 16
      lib/executor.js

@ -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)
}
}

Loading…
Cancel
Save