Skip to content

added fix for #3393#3394

Closed
tazayan wants to merge 3 commits into
PrismLibrary:masterfrom
tazayan:dev/eventstreaming
Closed

added fix for #3393#3394
tazayan wants to merge 3 commits into
PrismLibrary:masterfrom
tazayan:dev/eventstreaming

Conversation

@tazayan
Copy link
Copy Markdown

@tazayan tazayan commented Apr 26, 2026

Description of Change

Fixed #3393

tazayan added 3 commits April 25, 2026 22:55
Introduced EventStream<TPayload> for .NET 8+, providing a strongly-typed pub/sub event stream with a fixed-size rolling backlog using a ring buffer. Added multiple Subscribe overloads supporting thread options, strong/weak references, filtering, and backlog replay. Overrode publish and subscription logic for backlog management and thread safety. Included extensive unit tests covering all major behaviors and edge cases.
Renamed private fields in EventStream<TPayload> and Backlog<T>
to use a leading underscore (_) for consistency with C#
naming conventions. No functional changes were made.
Updated XML docs for EventStream<TPayload> to specify that backlogAction is always invoked synchronously on the publisher's thread, regardless of ThreadOption. Added remarks to distinguish thread marshalling behavior for backlogAction vs. action. Clarified lock usage during backlog snapshot and invocation timing.
Copy link
Copy Markdown

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

Implements the new EventStream<TPayload> event type requested in issue #3393, adding a pub/sub event that retains a rolling backlog and can replay it to late subscribers.

Changes:

  • Added EventStream<TPayload> implementation in Prism.Events with backlog replay + ring-buffer eviction.
  • Added extensive unit tests covering backlog replay, filtering, thread options, unsubscribe semantics, and weak/strong reference behavior.

Reviewed changes

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

File Description
src/Prism.Events/EventStream.cs New event type with rolling backlog, backlog replay on subscribe, and integration with Prism’s existing subscription model.
tests/Prism.Core.Tests/Events/EventStreamFixture.cs New test suite validating backlog behavior and parity with existing PubSubEvent semantics.

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

Comment thread src/Prism.Events/EventStream.cs
Comment thread src/Prism.Events/EventStream.cs
Comment on lines +248 to +252
finally
{
if (backlog != null)
ArrayPool<TPayload>.Shared.Return(backlog, clearArray: true);
}
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The pooled backlog array is always returned with clearArray: true. For value-type payloads this can add avoidable CPU cost; consider clearing only when needed (e.g., based on whether TPayload is a reference type / contains references).

Copilot uses AI. Check for mistakes.
Comment thread src/Prism.Events/EventStream.cs
Comment thread src/Prism.Events/EventStream.cs
Comment thread src/Prism.Events/EventStream.cs
Comment thread src/Prism.Events/EventStream.cs
Comment thread src/Prism.Events/EventStream.cs
@brianlagunas
Copy link
Copy Markdown
Member

Not accepting this PR. Details in the related issue #3393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Add a new EventStream<TPayload> event type to Prism.Events

3 participants