Skip to content

Commit

Permalink
expose max concurrent send streams
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Feb 5, 2021
1 parent 2c8c847 commit 52db920
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,12 @@ where
pub fn ping_pong(&mut self) -> Option<PingPong> {
self.inner.take_user_pings().map(PingPong::new)
}

/// Returns the maximum number of concurrent streams that may be initiated
/// by this client.
pub fn max_concurrent_send_streams(&self) -> usize {
self.inner.max_send_streams()
}
}

impl<T, B> Future for Connection<T, B>
Expand Down
6 changes: 6 additions & 0 deletions src/proto/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ where
self.settings.send_settings(settings)
}

/// Returns the maximum number of concurrent streams that may be initiated
/// by this peer.
pub(crate) fn max_send_streams(&self) -> usize {
self.streams.max_send_streams()
}

/// Returns `Ready` when the connection is ready to receive a frame.
///
/// Returns `RecvError` as this may raise errors that are caused by delayed
Expand Down
6 changes: 6 additions & 0 deletions src/proto/streams/counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ impl Counts {
}
}

/// Returns the maximum number of streams that can be initiated by this
/// peer.
pub(crate) fn max_send_streams(&self) -> usize {
self.max_send_streams
}

fn dec_num_streams(&mut self, stream: &mut store::Ptr) {
assert!(stream.is_counted);

Expand Down
4 changes: 4 additions & 0 deletions src/proto/streams/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,10 @@ where
Ok(())
}

pub(crate) fn max_send_streams(&self) -> usize {
self.inner.lock().unwrap().counts.max_send_streams()
}

#[cfg(feature = "unstable")]
pub fn num_active_streams(&self) -> usize {
let me = self.inner.lock().unwrap();
Expand Down
6 changes: 6 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ where
pub fn ping_pong(&mut self) -> Option<PingPong> {
self.connection.take_user_pings().map(PingPong::new)
}

/// Returns the maximum number of concurrent streams that may be initiated
/// by the server on this connection.
pub fn max_concurrent_send_streams(&self) -> usize {
self.connection.max_send_streams()
}
}

#[cfg(feature = "stream")]
Expand Down

0 comments on commit 52db920

Please sign in to comment.