perf(client): reduce an allocation per http2 connection
This commit is contained in:
@@ -37,7 +37,7 @@ tokio-executor = { version = "0.1.0", optional = true }
|
|||||||
tokio-io = "0.1"
|
tokio-io = "0.1"
|
||||||
tokio-reactor = { version = "0.1", optional = true }
|
tokio-reactor = { version = "0.1", optional = true }
|
||||||
tokio-tcp = { version = "0.1", optional = true }
|
tokio-tcp = { version = "0.1", optional = true }
|
||||||
want = "0.0.3"
|
want = "0.0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
num_cpus = "1.0"
|
num_cpus = "1.0"
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use futures::{Async, Poll, Stream};
|
use futures::{Async, Poll, Stream};
|
||||||
use futures::sync::{mpsc, oneshot};
|
use futures::sync::{mpsc, oneshot};
|
||||||
use want;
|
use want;
|
||||||
@@ -47,8 +45,8 @@ pub struct Sender<T, U> {
|
|||||||
/// Cannot poll the Giver, but can still use it to determine if the Receiver
|
/// Cannot poll the Giver, but can still use it to determine if the Receiver
|
||||||
/// has been dropped. However, this version can be cloned.
|
/// has been dropped. However, this version can be cloned.
|
||||||
pub struct UnboundedSender<T, U> {
|
pub struct UnboundedSender<T, U> {
|
||||||
// Only used for `is_closed`, since mpsc::UnboundedSender cannot be checked.
|
/// Only used for `is_closed`, since mpsc::UnboundedSender cannot be checked.
|
||||||
giver: Arc<want::Giver>,
|
giver: want::SharedGiver,
|
||||||
inner: mpsc::UnboundedSender<Envelope<T, U>>,
|
inner: mpsc::UnboundedSender<Envelope<T, U>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ impl<T, U> Sender<T, U> {
|
|||||||
|
|
||||||
pub fn unbound(self) -> UnboundedSender<T, U> {
|
pub fn unbound(self) -> UnboundedSender<T, U> {
|
||||||
UnboundedSender {
|
UnboundedSender {
|
||||||
giver: Arc::new(self.giver),
|
giver: self.giver.shared(),
|
||||||
inner: self.inner,
|
inner: self.inner,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user