| 1 | // Pipeline to manage the flow of frames |
| 2 | class Pipeline { |
| 3 | constructor() { |
| 4 | this.back = new BackFrame(); |
| 5 | this.mid = new FrontFrame("mid"); |
| 6 | this.front = new FrontFrame("front"); |
| 7 | } |
| 8 | |
| 9 | push(blob) { |
| 10 | this.back.swap(blob); |
| 11 | |
| 12 | if (!this.mid.loading && !this.mid.loaded) { |
| 13 | this.mid.load(this.back.consume()); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | consume() { |
| 18 | if (this.mid.loaded) { |
| 19 | const temp = this.mid; |
| 20 | this.mid = this.front; |
| 21 | this.front = temp; |
| 22 | this.mid.load(this.back.consume()); |
| 23 | } else if (!this.mid.loading) { |
| 24 | this.mid.load(this.back.consume()); |
| 25 | } |
| 26 | |
| 27 | return this.front.consume(); |
| 28 | } |
| 29 | |
| 30 | destroy() { |
| 31 | this.back.destroy(); |
| 32 | this.mid.destroy(); |
| 33 | this.front.destroy(); |
| 34 | } |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected