-
Notifications
You must be signed in to change notification settings - Fork 59
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
Keep sub alive when reading channel #506
Conversation
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
Very nice! 😎 |
...just checking the tests. they are still passing for me even after removing the GC magic. |
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.
LGTM
This is fixing the issue for SubscribeCore. Tests don't seem to fail (at least for me on my machine) when the GC fix isn't in place but that can be looked into in a follow up PR if you like.
Below are what I had to do to fail the tests when GC fixes weren't in place.
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
ef71ec9
to
97db5ad
Compare
Of course... I had it all working then simplified the tests to DRY it up, and I covered up the original failures. Just refactored them back to use Task.Run which now fail again for me when using the original |
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
Added a new benchmark for Subscribe, a side effect of the GC Handle is that the
|
Resolves #499
Resolves #505
Adds GC keepalive calls to
ActivityEndingMsgReader
in order to prevent sub from being GC'd while the channel reader is being interacted with.Learned about
GCHandle.Alloc
from this blog post - Using GC.KeepAlive in async methodsI left
RegisterSubAnchor
in place for now as I saw it was in-use still in the JetStream project. But if every sub there uses anActivityEndingMsgReader
it should be able to be eliminated.