Browse Source
Merge pull request #21305 from MarkCiliaVincenti/AsyncKeyedLockOptimizations
AsyncKeyedLock optimizations
pull/21329/head
maliming
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
5 additions and
6 deletions
-
Directory.Packages.props
-
framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLock.cs
|
|
|
@ -6,7 +6,7 @@ |
|
|
|
<PackageVersion Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.0.0" /> |
|
|
|
<PackageVersion Include="aliyun-net-sdk-sts" Version="3.1.2" /> |
|
|
|
<PackageVersion Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" /> |
|
|
|
<PackageVersion Include="AsyncKeyedLock" Version="7.0.2" /> |
|
|
|
<PackageVersion Include="AsyncKeyedLock" Version="7.1.3" /> |
|
|
|
<PackageVersion Include="Autofac" Version="8.1.0" /> |
|
|
|
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" /> |
|
|
|
<PackageVersion Include="Autofac.Extras.DynamicProxy" Version="7.1.0" /> |
|
|
|
|
|
|
|
@ -30,12 +30,11 @@ public class LocalAbpDistributedLock : IAbpDistributedLock, ISingletonDependency |
|
|
|
Check.NotNullOrWhiteSpace(name, nameof(name)); |
|
|
|
var key = DistributedLockKeyNormalizer.NormalizeKey(name); |
|
|
|
|
|
|
|
var timeoutReleaser = await _localSyncObjects.LockAsync(key, timeout, cancellationToken); |
|
|
|
if (!timeoutReleaser.EnteredSemaphore) |
|
|
|
var timeoutReleaser = await _localSyncObjects.LockOrNullAsync(key, timeout, cancellationToken); |
|
|
|
if (timeoutReleaser is not null) |
|
|
|
{ |
|
|
|
timeoutReleaser.Dispose(); |
|
|
|
return null; |
|
|
|
return new LocalAbpDistributedLockHandle(timeoutReleaser); |
|
|
|
} |
|
|
|
return new LocalAbpDistributedLockHandle(timeoutReleaser); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|