@@ -61,7 +61,6 @@ use bytes::{Buf, BytesMut};
61
61
use futures_util:: future;
62
62
use http:: { response, HeaderMap , Request , Response , StatusCode } ;
63
63
use quic:: StreamId ;
64
- use tokio:: sync:: mpsc;
65
64
66
65
use crate :: {
67
66
connection:: { self , ConnectionInner , ConnectionState , SharedStateRef } ,
@@ -74,6 +73,38 @@ use crate::{
74
73
} ;
75
74
use tracing:: { error, trace, warn} ;
76
75
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
+
77
108
/// Create a builder of HTTP/3 server connections
78
109
///
79
110
/// This function creates a [`Builder`] that carries settings that can
0 commit comments