@@ -18,7 +18,12 @@ pub fn unbounded_async<T: Unpin>() -> (Tx<T>, AsyncRx<T>) {
1818}
1919
2020/// Initiate a bounded channel that sender and receiver are async
21- pub fn bounded_async < T : Unpin > ( size : usize ) -> ( AsyncTx < T > , AsyncRx < T > ) {
21+ ///
22+ /// Special case: 0 size is not supported yet, threat it as 1 size for now.
23+ pub fn bounded_async < T : Unpin > ( mut size : usize ) -> ( AsyncTx < T > , AsyncRx < T > ) {
24+ if size == 0 {
25+ size = 1 ;
26+ }
2227 let ( tx, rx) = crossbeam:: channel:: bounded ( size) ;
2328 let send_wakers = SendWakersSingle :: new ( ) ;
2429 let recv_wakers = RecvWakersSingle :: new ( ) ;
@@ -30,7 +35,12 @@ pub fn bounded_async<T: Unpin>(size: usize) -> (AsyncTx<T>, AsyncRx<T>) {
3035}
3136
3237/// Initiate a bounded channel that sender is async, receiver is blocking
33- pub fn bounded_tx_async_rx_blocking < T : Unpin > ( size : usize ) -> ( AsyncTx < T > , Rx < T > ) {
38+ ///
39+ /// Special case: 0 size is not supported yet, threat it as 1 size for now.
40+ pub fn bounded_tx_async_rx_blocking < T : Unpin > ( mut size : usize ) -> ( AsyncTx < T > , Rx < T > ) {
41+ if size == 0 {
42+ size = 1 ;
43+ }
3444 let ( tx, rx) = crossbeam:: channel:: bounded ( size) ;
3545 let send_wakers = SendWakersSingle :: new ( ) ;
3646 let recv_wakers = RecvWakersBlocking :: new ( ) ;
@@ -42,7 +52,12 @@ pub fn bounded_tx_async_rx_blocking<T: Unpin>(size: usize) -> (AsyncTx<T>, Rx<T>
4252}
4353
4454/// Initiate a bounded channel that sender is blocking, receiver is sync
45- pub fn bounded_tx_blocking_rx_async < T > ( size : usize ) -> ( Tx < T > , AsyncRx < T > ) {
55+ ///
56+ /// Special case: 0 size is not supported yet, threat it as 1 size for now.
57+ pub fn bounded_tx_blocking_rx_async < T > ( mut size : usize ) -> ( Tx < T > , AsyncRx < T > ) {
58+ if size == 0 {
59+ size = 1 ;
60+ }
4661 let ( tx, rx) = crossbeam:: channel:: bounded ( size) ;
4762 let send_wakers = SendWakersBlocking :: new ( ) ;
4863 let recv_wakers = RecvWakersSingle :: new ( ) ;
0 commit comments