-
Notifications
You must be signed in to change notification settings - Fork 51
Refactor Connection to a synchronous state machine
#142
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
9bd4a34
Fix clippy warnings
thomaseizinger 9af35b8
Remove unnecessary `Option`
thomaseizinger 54296c5
Make `gargabe_collect` not async
thomaseizinger 6234e6f
Handle socket closing outside of `on_control_command`
thomaseizinger d5d5ef4
Handle GoAway logic outside of `on_stream_command`
thomaseizinger 6a55933
Remove `async` from a bunch of functions
thomaseizinger c1e805d
Introduce `Connection::poll` function
thomaseizinger e02bdbc
Minimise diff
thomaseizinger 3a6a374
Split `on_control_command`
thomaseizinger 5e64609
Use whitespace
thomaseizinger 3817398
Split `on_stream_command`
thomaseizinger 0ebd9cc
Prioritise control and stream commands over reading the socket
thomaseizinger b37e484
Fail if we want to double close a connection
thomaseizinger f776a43
Introduce internal `ConnectionState` enum
thomaseizinger d63cde2
Track closed state in connection state enum
thomaseizinger a1db18e
Inline `on_close_connection`
thomaseizinger fd886ee
Implement shutdown procedurally
thomaseizinger 527012d
Don't pause `control_receiver`
thomaseizinger f9d3f4b
Implement `ConnectionState::poll`
thomaseizinger 2df23f0
Implement `into_stream` by directly calling `poll_next`
thomaseizinger 6ca0d1f
Improve naming of `poll` fn on `ConnectionState`
thomaseizinger bb96cd9
Improve docs
thomaseizinger ff27080
Don't fail if connection got closed gracefully
thomaseizinger 527df19
Rename `Failing` to `Cleanup`
thomaseizinger 19ee6e8
Add docs to state variants
thomaseizinger 370f5bc
Track reply sender outside of `close` function
thomaseizinger 7dcecde
Handle `ControlCommand` outside of `ConnectionState::poll`
thomaseizinger fe7d000
Introduce `Frame::close_stream` ctor
thomaseizinger 2bae656
Move `Drop` impl from `Active` to `Connection`
thomaseizinger 47c684b
Implement connection closing as manual state machine
thomaseizinger 8279c27
Implement connection cleanup as manual state machine
thomaseizinger ce57e25
Don't require `T` to be `Send + 'static'`
thomaseizinger 0ac90a0
Rewrite `Control` to be a layer on top of `Connection`
thomaseizinger 79c1479
Make `control` as sister module of `connection`
thomaseizinger 3941cdc
Add test for poll-based API
thomaseizinger a0ba23b
Create workspace
thomaseizinger 654e38a
Remove comment and improve variable naming
thomaseizinger 1525cf8
Fix typo
thomaseizinger 27ed7ac
Match exhaustively
thomaseizinger 1ca32e6
Use doc link
thomaseizinger 63938b1
Bump version and add changelog entry
thomaseizinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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.
I am wondering whether we should
flushso early in thepollmethod, or whether it shouldn't be one of the last actions. Rational being that frequent flushing hurts performance, especially in case one can increase the batch instead.Just a thought. Needs more thought and potentially data to back it up.
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.
I couldn't find any consistent performance improvement in my benchmarks when moving this block of code up or down.
However, this got me thinking: We do we communicate via channels between the connection and the stream for writing but we use shared buffers when reading? We could just as easily have a buffer of frames in
Sharedand wake theConnectionwhenever we write any frames to that. This would allow us to drain the buffer of all streams in one go, without having to receive individual frames over a channel.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.
Thanks for testing. Let's keep as is.
I am decisive whether the connection should communicate with the stream via a channel or via plain
MutexandWaker. Whatever change we want to make, I think it should not happen within this pull request.