Skip to content

Commit 9696ae6

Browse files
majochaesbenbjerre
authored andcommitted
Ensure frameworkTcImportsCache mutations are threadsafe (dotnet#17795)
* ensure all frameworkTcImportsCache mutations are threadsafe * rn * not needed
1 parent fe53035 commit 9696ae6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Fixed
22

3+
* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))
34

45
### Added
56

src/Compiler/Service/IncrementalBuild.fs

+4-2
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,12 @@ type FrameworkImportsCache(size) =
507507
let frameworkTcImportsCache = AgedLookup<AnyCallerThreadToken, FrameworkImportsCacheKey, GraphNode<TcGlobals * TcImports>>(size, areSimilar=(fun (x, y) -> x = y))
508508

509509
/// Reduce the size of the cache in low-memory scenarios
510-
member _.Downsize() = frameworkTcImportsCache.Resize(AnyCallerThread, newKeepStrongly=0)
510+
member _.Downsize() = lock gate <| fun () ->
511+
frameworkTcImportsCache.Resize(AnyCallerThread, newKeepStrongly=0)
511512

512513
/// Clear the cache
513-
member _.Clear() = frameworkTcImportsCache.Clear AnyCallerThread
514+
member _.Clear() = lock gate <| fun () ->
515+
frameworkTcImportsCache.Clear AnyCallerThread
514516

515517
/// This function strips the "System" assemblies from the tcConfig and returns a age-cached TcImports for them.
516518
member _.GetNode(tcConfig: TcConfig, frameworkDLLs: AssemblyResolution list, nonFrameworkResolutions: AssemblyResolution list) =

0 commit comments

Comments
 (0)