Add user PING support (#346)
- Add `share::PingPong`, which can send `Ping`s, and poll for the `Pong` from the peer.
This commit is contained in:
@@ -38,6 +38,7 @@ pub use self::bytes::{Buf, BufMut, Bytes, BytesMut, IntoBuf};
|
||||
|
||||
pub use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
||||
pub use std::thread;
|
||||
pub use std::time::Duration;
|
||||
|
||||
// ===== Everything under here shouldn't be used =====
|
||||
|
||||
@@ -8,6 +8,19 @@ pub fn byte_str(s: &str) -> String<Bytes> {
|
||||
String::try_from(Bytes::from(s)).unwrap()
|
||||
}
|
||||
|
||||
pub fn yield_once() -> impl Future<Item=(), Error=()> {
|
||||
let mut yielded = false;
|
||||
futures::future::poll_fn(move || {
|
||||
if yielded {
|
||||
Ok(Async::Ready(()))
|
||||
} else {
|
||||
yielded = true;
|
||||
futures::task::current().notify();
|
||||
Ok(Async::NotReady)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn wait_for_capacity(stream: h2::SendStream<Bytes>, target: usize) -> WaitForCapacity {
|
||||
WaitForCapacity {
|
||||
stream: Some(stream),
|
||||
|
||||
Reference in New Issue
Block a user