@@ -23,6 +23,7 @@ use tokio::{
2323 sync:: { mpsc, mpsc:: Permit , oneshot} ,
2424 try_join,
2525} ;
26+ use tokio_util:: sync:: ReusableBoxFuture ;
2627
2728use super :: {
2829 AnyStorage , Cfg , ChMuxError , PROTOCOL_VERSION , PROTOCOL_VERSION_PORT_ID , PortReq ,
@@ -535,7 +536,7 @@ where
535536 }
536537 }
537538
538- let mut next_ping = get_next_ping ( ping_interval) . fuse ( ) . boxed ( ) ;
539+ let mut next_ping = ReusableBoxFuture :: new ( get_next_ping ( ping_interval) ) ;
539540 let mut need_flush = false ;
540541
541542 loop {
@@ -555,7 +556,7 @@ where
555556 break ;
556557 }
557558
558- next_ping = get_next_ping( ping_interval) . fuse ( ) . boxed ( ) ;
559+ next_ping. set ( get_next_ping( ping_interval) ) ;
559560 need_flush = true ;
560561 }
561562 None => break ,
@@ -564,7 +565,7 @@ where
564565
565566 ( ) = & mut next_ping => {
566567 Self :: feed_msg( TransportMsg :: new( MultiplexMsg :: Ping ) , sink) . await ?;
567- next_ping = get_next_ping( ping_interval) . fuse ( ) . boxed ( ) ;
568+ next_ping. set ( get_next_ping( ping_interval) ) ;
568569 need_flush = true ;
569570 }
570571
@@ -595,7 +596,8 @@ where
595596 }
596597 }
597598
598- let mut next_timeout = get_connection_timeout ( connection_timeout) . fuse ( ) . boxed ( ) ;
599+ let mut next_timeout = ReusableBoxFuture :: new ( get_connection_timeout ( connection_timeout) ) ;
600+
599601 while let Ok ( tx_permit) = tx. reserve ( ) . await {
600602 tokio:: select! {
601603 biased;
@@ -608,7 +610,7 @@ where
608610 break ;
609611 }
610612
611- next_timeout = get_connection_timeout( connection_timeout) . fuse ( ) . boxed ( ) ;
613+ next_timeout. set ( get_connection_timeout( connection_timeout) ) ;
612614 } ,
613615
614616 ( ) = & mut next_timeout => return Err ( ChMuxError :: Timeout ) ,
0 commit comments