Skip to content

Conversation

reem
Copy link
Contributor

@reem reem commented Sep 9, 2014

Abstract out NetworkStream for testing and extensibility, but use dynamic
dispatch to maintain ergonomics and not have a flood of generics.

Server and client benchmarks show that this makes very little difference in
performance and using dynamic dispatch here is significantly more
ergonomic.

This also bounds NetworkStream with Send to prevent incorrect
implementations.

@seanmonstar I checkout out your branch, rebased current master,
and then made these changes.

@reem reem force-pushed the network-stream branch 3 times, most recently from c3aaaaa to b32a7e9 Compare September 9, 2014 21:34
@reem
Copy link
Contributor Author

reem commented Sep 9, 2014

cc #17

This introduces a new Trait, NetworkStream, which abstracts over
the functionality provided by TcpStream so that it can be easily
mocked and extended in testing and hyper can be used for
other connection sources.
Copy link
Member

Choose a reason for hiding this comment

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

Did you want this to be boxed also, removing the generic? Or purposefully left alone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, my bad. I completely forgot to change anything but the server response :/

reem added 4 commits September 9, 2014 17:05
Server and client benchmarks show that this makes very little difference
in performance and using dynamic dispatch here is significantly more ergonomic.

This also bounds NetworkStream with Send to prevent incorrect implementations.

Allows the implementation of mock streams for testing and flexibility.

Fixes hyperium#5
…orkStream>

Also adds a convenience `abstract` method to NetworkStream for creating
Box<NetworkStream + Send> from a NetworkStream.
…g generics

The client benchmarks did not have to be changed at all for this whole
refactor, and the server benchmark only had to specify a single type parameter,
and only because it writes out the type of Listener, which is not normal
usage.
@reem
Copy link
Contributor Author

reem commented Sep 10, 2014

@seanmonstar Updated.

seanmonstar added a commit that referenced this pull request Sep 10, 2014
Abstract over NetworkStream using dynamic dispatch
@seanmonstar seanmonstar merged commit b903413 into hyperium:master Sep 10, 2014
@reem reem deleted the network-stream branch September 10, 2014 00:25
@reem reem mentioned this pull request Sep 10, 2014
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.

2 participants