-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add KeyedLock for per-key async locking and update local distributed … #24502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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