Skip to content
Open
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
16 changes: 6 additions & 10 deletions src/Compiler/Utilities/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ open FSharp.Compiler.Caches

[<Class>]
type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
let syncObj = obj ()

[<VolatileField>]
// TODO nullness - this is boxed to obj because of an attribute targets bug fixed in main, but not yet shipped (needs shipped 8.0.400)
let mutable valueFactory: objnull = valueFactory
Expand All @@ -34,7 +32,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
match valueFactory with
| null -> value
| _ ->
Monitor.Enter(syncObj)
Monitor.Enter(this)

try
match valueFactory with
Expand All @@ -44,7 +42,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
value <- (valueFactory |> unbox<unit -> 'T>) ()
valueFactory <- Unchecked.defaultof<_>
finally
Monitor.Exit(syncObj)
Monitor.Exit(this)

value

Expand Down Expand Up @@ -153,8 +151,6 @@ module internal PervasiveAutoOpens =

[<AbstractClass>]
type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) =
let syncObj = obj ()

let mutable arrayStore: (_ array | null) = null
let mutable dictStore: (_ | null) = null

Expand All @@ -164,7 +160,7 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) =
match arrayStore with
| NonNull value -> value
| _ ->
Monitor.Enter(syncObj)
Monitor.Enter(this)

try
match arrayStore with
Expand All @@ -176,14 +172,14 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) =
func <- Unchecked.defaultof<_>
freshArray
finally
Monitor.Exit(syncObj)
Monitor.Exit(this)

member this.GetDictionary() =
match dictStore with
| NonNull value -> value
| _ ->
let array = this.GetArray()
Monitor.Enter(syncObj)
Monitor.Enter(this)

try
match dictStore with
Expand All @@ -193,7 +189,7 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) =
dictStore <- dict
dict
finally
Monitor.Exit(syncObj)
Monitor.Exit(this)

abstract CreateDictionary: 'T[] -> IDictionary<'TDictKey, 'TDictValue>

Expand Down
Loading