added fix for #3393#3394
Closed
tazayan wants to merge 3 commits into
Closed
Conversation
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.
There was a problem hiding this comment.
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 inPrism.Eventswith 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 on lines
+248
to
+252
| finally | ||
| { | ||
| if (backlog != null) | ||
| ArrayPool<TPayload>.Shared.Return(backlog, clearArray: true); | ||
| } |
There was a problem hiding this comment.
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).
Member
|
Not accepting this PR. Details in the related issue #3393 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Fixed #3393