From 4cf6bc5d14d391418f8e2fc8a30836ee1ac774d3 Mon Sep 17 00:00:00 2001 From: taikulawo Date: Wed, 25 Dec 2024 11:13:32 +0800 Subject: [PATCH] add active stream prototype --- src/client.rs | 1 - src/proto/connection.rs | 8 +++++++- src/proto/streams/streams.rs | 1 - src/server.rs | 9 +++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index bba24170..f6ea04dd 100644 --- a/src/client.rs +++ b/src/client.rs @@ -582,7 +582,6 @@ where } } -#[cfg(feature = "unstable")] impl SendRequest where B: Buf, diff --git a/src/proto/connection.rs b/src/proto/connection.rs index 43774c6f..46dbc316 100644 --- a/src/proto/connection.rs +++ b/src/proto/connection.rs @@ -181,6 +181,10 @@ where pub(crate) fn max_recv_streams(&self) -> usize { self.inner.streams.max_recv_streams() } + /// Returns the number of active stream + pub(crate) fn active_streams(&self) -> usize { + self.inner.streams.num_active_streams() + } #[cfg(feature = "unstable")] pub fn num_wired_streams(&self) -> usize { @@ -303,7 +307,9 @@ where ) { (Some(sleep), _) => { ready!(sleep.as_mut().poll(cx)); - self.inner.as_dyn().go_away_now(Reason::KEEPALIVE_TIMEOUT); + self.inner + .as_dyn() + .go_away_now(Reason::KEEPALIVE_TIMEOUT); continue 'outer; } (None, Some(timeout)) => { diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 875b6103..b2f7918f 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -1008,7 +1008,6 @@ where self.inner.lock().unwrap().counts.max_recv_streams() } - #[cfg(feature = "unstable")] pub fn num_active_streams(&self) -> usize { let me = self.inner.lock().unwrap(); me.store.num_active_streams() diff --git a/src/server.rs b/src/server.rs index 69734f6a..1e74d3f8 100644 --- a/src/server.rs +++ b/src/server.rs @@ -584,6 +584,15 @@ where self.connection.max_recv_streams() } + /// Returns whether has stream alive + pub fn has_streams_or_other_references(&self) -> bool { + self.connection.has_streams_or_other_references() + } + /// Returns the number of current active stream. + pub fn active_stream(&self) -> usize { + self.connection.active_streams() + } + // Could disappear at anytime. #[doc(hidden)] #[cfg(feature = "unstable")]