Skip to content

Add ProgressMuxer and DelegateProgress utilities#48

Merged
Tyrrrz merged 7 commits intoprimefrom
copilot/add-progress-muxer-utility
Apr 17, 2026
Merged

Add ProgressMuxer and DelegateProgress utilities#48
Tyrrrz merged 7 commits intoprimefrom
copilot/add-progress-muxer-utility

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Ports ProgressMuxer from Onova into PowerKit as a source-only utility. Combines weighted IProgress<double> inputs into a single aggregated output.

Changes

  • PowerKit/ProgressMuxer.cs — core implementation

    • Guarded with #if NET40_OR_GREATER || NETSTANDARD || NET (IProgress<T> unavailable on net35)
    • Uses System.Threading.Lock and EnterScope() (polyfilled by PolyShim 2.10.0 for all pre-.NET 9 targets)
    • Uses Interlocked.Increment for thread-safe input index allocation in CreateInput
    • Returns a DelegateProgress<double> from CreateInput rather than Progress<T>, which avoids async dispatch via SynchronizationContext
  • PowerKit/DelegateProgress.cs — new standalone utility type

    • internal sealed class DelegateProgress<T> : IProgress<T> that delegates reporting to an Action<T>
    • Guarded with #if NET40_OR_GREATER || NETSTANDARD || NET
    • Usable independently of ProgressMuxer
  • PowerKit.Tests/ProgressMuxerTests.cs — covers single input, weighted input, and multiple weighted inputs

Usage

var muxer = new ProgressMuxer(outputProgress);

var downloadProgress = muxer.CreateInput(weight: 0.7);
var extractProgress  = muxer.CreateInput(weight: 0.3);

// Each input contributes proportionally to the combined output
downloadProgress.Report(1.0); // output sees 0.7
extractProgress.Report(1.0);  // output sees 1.0

DelegateProgress<T> can also be used standalone:

IProgress<double> progress = new DelegateProgress<double>(p => Console.WriteLine(p));
progress.Report(0.5); // prints 0.5

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/5703499f-a02f-4b43-9578-ef84f7514bc2

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz marked this pull request as ready for review April 17, 2026 12:50
Copilot AI review requested due to automatic review settings April 17, 2026 12:50
Comment thread PowerKit/ProgressMuxer.cs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.56%. Comparing base (e1aaff9) to head (a7b0e90).
⚠️ Report is 5 commits behind head on prime.

Additional details and impacted files
@@            Coverage Diff             @@
##            prime      #48      +/-   ##
==========================================
+ Coverage   94.36%   94.56%   +0.19%     
==========================================
  Files          82       92      +10     
  Lines        1740     1951     +211     
  Branches      141      152      +11     
==========================================
+ Hits         1642     1845     +203     
- Misses         72       77       +5     
- Partials       26       29       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread PowerKit/ProgressMuxer.cs Outdated
Comment thread PowerKit/ProgressMuxer.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only utility (ProgressMuxer) to aggregate multiple weighted IProgress<double> inputs into a single output progress reporter, along with tests validating basic aggregation behavior.

Changes:

  • Added ProgressMuxer implementation that combines multiple weighted progress inputs into one output.
  • Added unit tests for single input, weighted input, and multiple weighted inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
PowerKit/ProgressMuxer.cs Introduces ProgressMuxer + internal delegate-based IProgress<double> input implementation.
PowerKit.Tests/ProgressMuxerTests.cs Adds coverage for aggregation behavior across different input/weight scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit.Tests/ProgressMuxerTests.cs Outdated
Comment thread PowerKit/ProgressMuxer.cs Outdated
Comment thread PowerKit/ProgressMuxer.cs Outdated
Comment thread PowerKit/ProgressMuxer.cs
Tyrrrz and others added 2 commits April 17, 2026 15:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ressMuxer

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/662d174c-e8b7-4753-b581-fed6a70a59d3

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 17, 2026
Comment thread PowerKit/ProgressMuxer.cs Outdated
…ne utility type

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ad02ed49-8949-4ff7-a3e4-873109152869

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot AI changed the title Add ProgressMuxer utility Add ProgressMuxer and DelegateProgress utilities Apr 17, 2026
Copilot AI requested a review from Tyrrrz April 17, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants