mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-23 11:45:25 +00:00
H3: make Request yeild Connection's private
This commit is contained in:
@@ -106,8 +106,8 @@ impl ConnectionRef {
|
||||
|
||||
pub(crate) struct ConnectionInner {
|
||||
pub inner: Connection,
|
||||
pub requests: VecDeque<(SendStream, RecvStream)>,
|
||||
pub requests_task: Option<Waker>,
|
||||
requests: VecDeque<(SendStream, RecvStream)>,
|
||||
requests_task: Option<Waker>,
|
||||
side: Side,
|
||||
driver: Option<Waker>,
|
||||
incoming_bi: IncomingBiStreams,
|
||||
@@ -135,6 +135,16 @@ impl ConnectionInner {
|
||||
Ok(self.inner.is_closing() && self.inner.requests_in_flight() == 0)
|
||||
}
|
||||
|
||||
pub fn next_request(&mut self, cx: &mut Context) -> Option<(SendStream, RecvStream)> {
|
||||
match self.requests.pop_front() {
|
||||
Some(x) => Some(x),
|
||||
None => {
|
||||
self.requests_task = Some(cx.waker().clone());
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wake(&mut self) {
|
||||
if let Some(w) = self.driver.take() {
|
||||
w.wake();
|
||||
|
||||
+5
-12
@@ -168,18 +168,11 @@ pub struct IncomingRequest(ConnectionRef);
|
||||
impl Stream for IncomingRequest {
|
||||
type Item = RecvRequest;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
let (send, recv) = {
|
||||
let conn = &mut self.0.h3.lock().unwrap();
|
||||
match conn.requests.pop_front() {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
conn.requests_task = Some(cx.waker().clone());
|
||||
return Poll::Pending;
|
||||
}
|
||||
}
|
||||
};
|
||||
Poll::Ready(Some(RecvRequest::new(recv, send, self.0.clone())))
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
match self.0.h3.lock().unwrap().next_request(cx) {
|
||||
Some((s, r)) => Poll::Ready(Some(RecvRequest::new(r, s, self.0.clone()))),
|
||||
None => Poll::Pending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user