From 0f1e6dc11a750b7c15add8676728f257a9377a1a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 30 Apr 2023 13:30:09 +0200 Subject: [PATCH] Remove unnecessary CanvasEffect.lockObject field --- src/ComputeSharp.D2D1.UI/CanvasEffect.Interop.cs | 2 +- src/ComputeSharp.D2D1.UI/CanvasEffect.cs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ComputeSharp.D2D1.UI/CanvasEffect.Interop.cs b/src/ComputeSharp.D2D1.UI/CanvasEffect.Interop.cs index e184095a..6628c398 100644 --- a/src/ComputeSharp.D2D1.UI/CanvasEffect.Interop.cs +++ b/src/ComputeSharp.D2D1.UI/CanvasEffect.Interop.cs @@ -69,7 +69,7 @@ unsafe partial class CanvasEffect [MemberNotNull(nameof(canvasImage))] private ICanvasImage GetCanvasImage() { - lock (this.lockObject) + lock (this.transformNodes) { default(ObjectDisposedException).ThrowIf(this.isDisposed, this); diff --git a/src/ComputeSharp.D2D1.UI/CanvasEffect.cs b/src/ComputeSharp.D2D1.UI/CanvasEffect.cs index c7496205..276bd8aa 100644 --- a/src/ComputeSharp.D2D1.UI/CanvasEffect.cs +++ b/src/ComputeSharp.D2D1.UI/CanvasEffect.cs @@ -15,11 +15,6 @@ namespace ComputeSharp.D2D1.WinUI; /// public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.Interface { - /// - /// Lock object used to synchronize calls to APIs. - /// - private readonly object lockObject = new(); - /// /// The mapping of registered transform nodes for the current effect graph. /// @@ -137,7 +132,7 @@ public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.I /// protected void InvalidateEffectGraph(InvalidationType invalidationType = InvalidationType.Update) { - lock (this.lockObject) + lock (this.transformNodes) { // If the effect graph should be created again, dispose the image and throw it away if (invalidationType == InvalidationType.Creation) @@ -212,7 +207,7 @@ public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.I // the lock itself might have already been collected by the time this code runs, which would lead the lock // statement to throw a NullReferenceException. So if a finalizer is running, just let objects be collected // on their own. This is fine here since there are no unmanaged references to free, but just managed wrappers. - lock (this.lockObject) + lock (this.transformNodes) { DisposeEffectGraph(); }