| 31 | * stop. If one program stops, the other is also stopped automatically. |
| 32 | */ |
| 33 | export class CombinedProgram implements IProgram { |
| 34 | public readonly stopped = Promise.race([ |
| 35 | this.a.stopped.then(async r => (await this.b.stop()) && r), |
| 36 | this.b.stopped.then(async r => (await this.a.stop()) && r), |
| 37 | ]); |
| 38 | |
| 39 | constructor(private readonly a: IProgram, private readonly b: IProgram) {} |
| 40 | |
| 41 | public gotTelemetery(telemetry: IProcessTelemetry) { |
| 42 | this.a.gotTelemetery(telemetry); |
| 43 | this.b.gotTelemetery(telemetry); |
| 44 | } |
| 45 | |
| 46 | public async stop(): Promise<IStopMetadata> { |
| 47 | const r = await Promise.all([this.a.stop(), this.b.stop()]); |
| 48 | return r[0]; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Program created from a subprocess. |