Skip to content

Commit

Permalink
sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
majocha committed May 9, 2024
1 parent 27dd989 commit 8c77c0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/DiagnosticsLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ type StackGuard(maxDepth: int, name: string) =
GetEnvInteger ("FSHARP_" + name + "StackGuardDepth") StackGuard.DefaultDepth

module MultipleDiagnosticsLoggers =

let Parallel computations =
let computationsWithLoggers, diagnosticsReady =
[
Expand Down Expand Up @@ -942,6 +943,8 @@ module MultipleDiagnosticsLoggers =
let results = ResizeArray()

for computation in computations do
// Encapsulate computation's diagnostics scope.
use _ = new CompilationGlobalsScope()
let! result = computation
results.Add result

Expand Down
13 changes: 7 additions & 6 deletions src/Compiler/Facilities/DiagnosticsLogger.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,13 @@ type CompilationGlobalsScope =

module MultipleDiagnosticsLoggers =

/// Execute computations using Async.Parallel.
/// Captures the diagnostics in correct order and keeps a common error count for all computations.
/// When done, restores caller's build phase and diagnostics logger, commiting captured diagnostics.
/// Runs computations using Async.Parallel.
/// Capturing the diagnostics from each separately.
/// When done, restores caller's BuildPhase and DiagnosticsLogger
/// and commits captured diagnostics preserving the order.
val Parallel: computations: Async<'T> seq -> Async<'T array>

/// Execute computations using Async.Sequential.
/// Captures the diagnostics in correct order and keeps a common error count for all computations.
/// When done, restores caller's build phase and diagnostics logger, commiting captured diagnostics.
/// Run computations sequentially starting on current thread
/// using caller's DiagnosticsLogger and BuildPhase for each computation.
/// When done, restores caller's BuildPhase and DiagnosticsLogger.
val Sequential: computations: Async<'T> seq -> Async<'T array>

0 comments on commit 8c77c0c

Please sign in to comment.