(this: ScopeImpl, exit)
| 3249 | }) |
| 3250 | }, |
| 3251 | close(this: ScopeImpl, exit) { |
| 3252 | return core.suspend(() => { |
| 3253 | if (this.state._tag === "Closed") { |
| 3254 | return core.void |
| 3255 | } |
| 3256 | const finalizers = Array.from(this.state.finalizers.values()).reverse() |
| 3257 | this.state = { _tag: "Closed", exit } |
| 3258 | if (finalizers.length === 0) { |
| 3259 | return core.void |
| 3260 | } |
| 3261 | return executionStrategy.isSequential(this.strategy) ? |
| 3262 | pipe( |
| 3263 | core.forEachSequential(finalizers, (fin) => core.exit(fin(exit))), |
| 3264 | core.flatMap((results) => |
| 3265 | pipe( |
| 3266 | core.exitCollectAll(results), |
| 3267 | Option.map(core.exitAsVoid), |
| 3268 | Option.getOrElse(() => core.exitVoid) |
| 3269 | ) |
| 3270 | ) |
| 3271 | ) : |
| 3272 | executionStrategy.isParallel(this.strategy) ? |
| 3273 | pipe( |
| 3274 | forEachParUnbounded(finalizers, (fin) => core.exit(fin(exit)), false), |
| 3275 | core.flatMap((results) => |
| 3276 | pipe( |
| 3277 | core.exitCollectAll(results, { parallel: true }), |
| 3278 | Option.map(core.exitAsVoid), |
| 3279 | Option.getOrElse(() => core.exitVoid) |
| 3280 | ) |
| 3281 | ) |
| 3282 | ) : |
| 3283 | pipe( |
| 3284 | forEachParN(finalizers, this.strategy.parallelism, (fin) => core.exit(fin(exit)), false), |
| 3285 | core.flatMap((results) => |
| 3286 | pipe( |
| 3287 | core.exitCollectAll(results, { parallel: true }), |
| 3288 | Option.map(core.exitAsVoid), |
| 3289 | Option.getOrElse(() => core.exitVoid) |
| 3290 | ) |
| 3291 | ) |
| 3292 | ) |
| 3293 | }) |
| 3294 | }, |
| 3295 | addFinalizer(this: ScopeImpl, fin) { |
| 3296 | return core.suspend(() => { |
| 3297 | if (this.state._tag === "Closed") { |
nothing calls this directly
no test coverage detected