From 917069fdf59909457cd552b92b40f0d0eca8de39 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 15 Dec 2025 18:05:17 +0800 Subject: [PATCH] Refactor LocalAbpDistributedLockHandle to use SemaphoreSlim --- .../LocalAbpDistributedLockHandle.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs b/framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs index d08451657e..5ffe95af5e 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs @@ -1,20 +1,21 @@ -using System; +using System.Threading; using System.Threading.Tasks; -namespace Volo.Abp.DistributedLocking; - -public class LocalAbpDistributedLockHandle : IAbpDistributedLockHandle +namespace Volo.Abp.DistributedLocking { - private readonly IDisposable _disposable; - - public LocalAbpDistributedLockHandle(IDisposable disposable) + public class LocalAbpDistributedLockHandle : IAbpDistributedLockHandle { - _disposable = disposable; - } + private readonly SemaphoreSlim _semaphore; - public ValueTask DisposeAsync() - { - _disposable.Dispose(); - return default; + public LocalAbpDistributedLockHandle(SemaphoreSlim semaphore) + { + _semaphore = semaphore; + } + + public ValueTask DisposeAsync() + { + _semaphore.Release(); + return default; + } } }