| 776 | * time. |
| 777 | */ |
| 778 | const beginRead = ( |
| 779 | root: number[], |
| 780 | pure: boolean, |
| 781 | engine: ComputeEngine, |
| 782 | numericApproximation: boolean | undefined |
| 783 | ): Expression | undefined => { |
| 784 | const readKey = readKeyOf(engine, numericApproximation); |
| 785 | const read: SequenceRead = { |
| 786 | signal: {}, |
| 787 | terms: new Map(), |
| 788 | pending: new Set(), |
| 789 | missing: undefined, |
| 790 | attempting: false, |
| 791 | attemptEpoch: 0, |
| 792 | count: 0, |
| 793 | guard: beginStoreGuard(), |
| 794 | }; |
| 795 | reads.set(readKey, read); |
| 796 | activeSequenceReads += 1; |
| 797 | try { |
| 798 | return pure |
| 799 | ? computeTerm(root, read, engine, numericApproximation) |
| 800 | : computeRecursively(root, read, engine, numericApproximation); |
| 801 | } catch (e) { |
| 802 | // The signal of this read was thrown where no computation of the |
| 803 | // read receives it. The term is declined: the signal must not get |
| 804 | // out of the read. |
| 805 | if (e === read.signal) return undefined; |
| 806 | throw e; |
| 807 | } finally { |