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. |
mtmk
left a comment
There was a problem hiding this comment.
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
ActivityEndingMsgReaderin order to prevent sub from being GC'd while the channel reader is being interacted with.Learned about
GCHandle.Allocfrom this blog post - Using GC.KeepAlive in async methodsI left
RegisterSubAnchorin place for now as I saw it was in-use still in the JetStream project. But if every sub there uses anActivityEndingMsgReaderit should be able to be eliminated.