@@ -61,7 +61,6 @@ use bytes::{Buf, BytesMut};
6161use futures_util:: future;
6262use http:: { response, HeaderMap , Request , Response , StatusCode } ;
6363use quic:: StreamId ;
64- use tokio:: sync:: mpsc;
6564
6665use crate :: {
6766 connection:: { self , ConnectionInner , ConnectionState , SharedStateRef } ,
@@ -74,6 +73,38 @@ use crate::{
7473} ;
7574use tracing:: { error, trace, warn} ;
7675
76+ #[ cfg( all( feature = "tokio" , not( feature = "async-channel" ) ) ) ]
77+ use tokio:: sync:: mpsc;
78+
79+ #[ cfg( feature = "async-channel" ) ]
80+ mod mpsc {
81+ use futures_util:: StreamExt ;
82+ use std:: task:: { Context , Poll } ;
83+
84+ pub fn unbounded_channel < T > ( ) -> ( UnboundedSender < T > , UnboundedReceiver < T > ) {
85+ let ( sender, receiver) = async_channel:: unbounded ( ) ;
86+ ( UnboundedSender ( sender) , UnboundedReceiver ( receiver) )
87+ }
88+
89+ #[ derive( Clone ) ]
90+ pub struct UnboundedSender < T > ( async_channel:: Sender < T > ) ;
91+
92+ impl < T > UnboundedSender < T > {
93+ pub fn send ( & self , msg : T ) -> Result < ( ) , async_channel:: TrySendError < T > > {
94+ self . 0 . try_send ( msg)
95+ }
96+ }
97+
98+ #[ derive( Clone ) ]
99+ pub struct UnboundedReceiver < T > ( async_channel:: Receiver < T > ) ;
100+
101+ impl < T > UnboundedReceiver < T > {
102+ pub fn poll_recv ( & mut self , cx : & mut Context ) -> Poll < Option < T > > {
103+ self . 0 . poll_next_unpin ( cx)
104+ }
105+ }
106+ }
107+
77108/// Create a builder of HTTP/3 server connections
78109///
79110/// This function creates a [`Builder`] that carries settings that can
0 commit comments