From 82208bd5edba4593ee2ba5a702c94cf9020d0e69 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Thu, 25 Apr 2024 23:08:22 +0300 Subject: [PATCH 1/2] Add volatile to valueFactory --- src/Compiler/Utilities/illib.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index fca3cd54605..c697911d530 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -14,7 +14,7 @@ open System.Runtime.CompilerServices [] type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = let syncObj = obj () - let mutable valueFactory = valueFactory + let [] mutable valueFactory = valueFactory let mutable value = value new(valueFactory: unit -> 'T) = InterruptibleLazy(Unchecked.defaultof<_>, valueFactory) @@ -28,9 +28,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = match box valueFactory with | null -> value | _ -> - Monitor.Enter(syncObj) - try match box valueFactory with | null -> () From 292b246f3bdcd70b3e66dc7245488654859b9303 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Thu, 25 Apr 2024 23:26:36 +0300 Subject: [PATCH 2/2] reformat --- src/Compiler/Utilities/illib.fs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index c697911d530..b065018e382 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -14,7 +14,10 @@ open System.Runtime.CompilerServices [] type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = let syncObj = obj () - let [] mutable valueFactory = valueFactory + + [] + let mutable valueFactory = valueFactory + let mutable value = value new(valueFactory: unit -> 'T) = InterruptibleLazy(Unchecked.defaultof<_>, valueFactory) @@ -29,6 +32,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = | null -> value | _ -> Monitor.Enter(syncObj) + try match box valueFactory with | null -> ()