Skip to content

Commit

Permalink
Add volatile to InterruptibleLazy valueFactory (#17090)
Browse files Browse the repository at this point in the history
* Add volatile to valueFactory

* reformat

---------

Co-authored-by: Petr <psfinaki@users.noreply.github.com>
  • Loading branch information
DedSec256 and psfinaki authored Apr 26, 2024
1 parent 8b51fa7 commit f4bd54c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Compiler/Utilities/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ open System.Runtime.CompilerServices
[<Class>]
type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
let syncObj = obj ()

[<VolatileField>]
let mutable valueFactory = valueFactory

let mutable value = value

new(valueFactory: unit -> 'T) = InterruptibleLazy(Unchecked.defaultof<_>, valueFactory)
Expand All @@ -28,7 +31,6 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
match box valueFactory with
| null -> value
| _ ->

Monitor.Enter(syncObj)

try
Expand Down

0 comments on commit f4bd54c

Please sign in to comment.