From a6e175c30506db58fb338d10ec3d6769f235b375 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:38:20 +0100 Subject: [PATCH] threadsafe events collection --- .../CompilerService/AsyncMemoize.fs | 4 ++-- .../FSharpChecker/TransparentCompiler.fs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs index e031aa9cbb9..e178ccaa911 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs @@ -15,14 +15,14 @@ let tap f x = f x; x let internal record (cache: AsyncMemoize<_,_,_>) = - let events = ResizeArray() + let events = Collections.Concurrent.ConcurrentQueue() let waitForIdle() = SpinWait.SpinUntil(fun () -> not cache.Updating) waitForIdle() cache.Event |> Event.map (fun (e, (_, k, _)) -> e, k) - |> Event.add events.Add + |> Event.add events.Enqueue let getEvents () = waitForIdle() diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index b41963df66d..b05096303d4 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -31,7 +31,7 @@ let fileName fileId = $"File%s{fileId}.fs" let internal recordAllEvents groupBy = let mutable cache : AsyncMemoize<_,_,_> option = None - let events = ResizeArray() + let events = ConcurrentQueue() let waitForIdle() = SpinWait.SpinUntil(fun () -> not cache.Value.Updating) @@ -40,7 +40,7 @@ let internal recordAllEvents groupBy = waitForIdle() cache.Value.Event |> Event.map (fun (e, k) -> groupBy k, e) - |> Event.add events.Add + |> Event.add events.Enqueue let getEvents () = waitForIdle()