Skip to content

Commit f4bd54c

Browse files
DedSec256psfinaki
andauthored
Add volatile to InterruptibleLazy valueFactory (#17090)
* Add volatile to valueFactory * reformat --------- Co-authored-by: Petr <[email protected]>
1 parent 8b51fa7 commit f4bd54c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Compiler/Utilities/illib.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ open System.Runtime.CompilerServices
1414
[<Class>]
1515
type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
1616
let syncObj = obj ()
17+
18+
[<VolatileField>]
1719
let mutable valueFactory = valueFactory
20+
1821
let mutable value = value
1922

2023
new(valueFactory: unit -> 'T) = InterruptibleLazy(Unchecked.defaultof<_>, valueFactory)
@@ -28,7 +31,6 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
2831
match box valueFactory with
2932
| null -> value
3033
| _ ->
31-
3234
Monitor.Enter(syncObj)
3335

3436
try

0 commit comments

Comments
 (0)