Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/22a8dd53-6d26-41cf-8f63-f07663947b4d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/cd5ae709-0ce3-4397-b725-d8a7a9f7938f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a ResizableSemaphore concurrency primitive to PowerKit, allowing the maximum concurrency level to be adjusted at runtime.
Changes:
- Introduces
ResizableSemaphorewith async acquire/release semantics and dynamicMaxCountupdates. - Adds unit tests covering acquisition limits, blocking behavior, cancellation, disposal behavior, and unblocking via
MaxCountchanges.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| PowerKit/ResizableSemaphore.cs | Implements the resizable semaphore and its disposable access handle. |
| PowerKit.Tests/ResizableSemaphoreTests.cs | Adds behavioral tests for acquire/release, cancellation, disposal, and resizing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/d0027c65-1201-42d6-b9da-3b4dd425d371 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/80a4d878-41af-4013-87ed-8ca860288a5c Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot ResizableSemaphoreAccess can be replaced with Disposable.Create |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prime #71 +/- ##
==========================================
+ Coverage 93.93% 93.99% +0.06%
==========================================
Files 130 132 +2
Lines 2557 2616 +59
Branches 202 205 +3
==========================================
+ Hits 2402 2459 +57
- Misses 112 113 +1
- Partials 43 44 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…e-semaphore-utility Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
… style Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/0bfd060f-27c8-42ea-b9b8-d2640d47a8a6 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot fix formatting please |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/a218a6ce-6e25-4e3f-b106-d08a4ae8e5cd Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Ports
ResizableSemaphorefrom YoutubeDownloader into PowerKit — a semaphore whose max concurrency count can be adjusted at runtime.Implementation
PowerKit/ResizableSemaphore.cs#if NET40_OR_GREATER || NETSTANDARD || NETfile guardLock+EnterScope()(PolyShim) instead ofobject+lockRefresh()acquires_lockitself; all callers release the lock before callingRefresh(), avoiding re-entrancy issues with .NET 9's non-reentrantSystem.Threading.Lock_maxCountbacking field inlined using C# 13fieldkeyword; getter is lock-free (get => field) soRefresh()can readMaxCountwithout re-entering the lockAcquiredAccessfile class replaced withDisposable.Create(Release)— no separate type neededawait usingonCancellationTokenRegistrationreplaced withusing var—IAsyncDisposableon that type is .NET 6+ onlyConfigureAwait(false)on the awaited taskpartial classdeclarations merged into onePowerKit.Tests/ResizableSemaphoreTests.cs— 4 consolidated tests covering blocking at limit, cancellation,MaxCountchanges unblocking waiters, and disposal behaviourUsage