Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate lock-object #1493

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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)
Loading