Skip to content

Commit

Permalink
Merge pull request #1493 from Thorium/fix1466
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermp authored Nov 15, 2023
2 parents d1e479f + ac25c6f commit 69dfe0e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ module internal ReflectionHelpers =
type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
inherit TypeProviderForNamespaces(config, ?assemblyReplacementMap = assemblyReplacementMap)

let lockObj = Object()
let disposeActions = ResizeArray()

static let mutable idCount = 0
Expand All @@ -90,7 +91,7 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
do idCount <- idCount + 1

let dispose typeNameOpt =
lock disposeActions (fun () ->
lock lockObj (fun () ->
for i = disposeActions.Count - 1 downto 0 do
let disposeAction = disposeActions.[i]
let discard = disposeAction typeNameOpt
Expand All @@ -115,7 +116,7 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
| _ -> None)

member _.AddDisposeAction action =
lock disposeActions (fun () -> disposeActions.Add action)
lock lockObj (fun () -> disposeActions.Add action)

member _.InvalidateOneType typeName =
(use _holder = logTime "InvalidateOneType" (sprintf "%s in %O [%d]" typeName x id)
Expand Down

0 comments on commit 69dfe0e

Please sign in to comment.