Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new KeyedLock utility class for per-key asynchronous locking based on a Stack Overflow solution, and refactors the local distributed locking implementation to use this new utility instead of managing SemaphoreSlim instances directly.
- Adds
KeyedLockstatic class providing lock/try-lock operations with per-key synchronization - Refactors
LocalAbpDistributedLockto delegate toKeyedLockinstead of managing semaphores directly - Simplifies
LocalAbpDistributedLockHandleto wrap genericIDisposableinstead ofSemaphoreSlim
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| framework/src/Volo.Abp.Core/Volo/Abp/Threading/KeyedLock.cs | New static utility class implementing per-key async locking with reference counting and automatic cleanup |
| framework/test/Volo.Abp.Core.Tests/Volo/Abp/Threading/KeyedLock_Tests.cs | Comprehensive test suite for KeyedLock covering locking, timeouts, cancellation, and concurrency scenarios |
| framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLock.cs | Refactored to use KeyedLock instead of ConcurrentDictionary of SemaphoreSlim instances |
| framework/src/Volo.Abp.DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs | Simplified to wrap generic IDisposable instead of SemaphoreSlim directly, but missing namespace declaration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs
Outdated
Show resolved
Hide resolved
...DistributedLocking.Abstractions/Volo/Abp/DistributedLocking/LocalAbpDistributedLockHandle.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Stephen Cleary's solution: https://stackoverflow.com/questions/31138179/asynchronous-locking-based-on-a-key/31194647#31194647