1- use std:: {
2- collections:: HashMap ,
3- ops:: Add ,
4- sync:: {
5- atomic:: { AtomicU32 , Ordering } ,
6- Arc , LazyLock ,
7- } ,
8- } ;
1+ use std:: sync:: atomic:: { AtomicU32 , Ordering } ;
2+ use std:: sync:: { Arc , LazyLock , Mutex } ;
3+ use std:: { collections:: HashMap , ops:: Add } ;
94
105use crate :: {
116 client:: {
@@ -19,15 +14,16 @@ use crate::{
1914 server,
2015 service:: { Request , Response , Service } ,
2116} ;
22- use tokio:: sync:: { mpsc, oneshot, Mutex , Notify } ;
17+ use tokio:: sync:: { mpsc, oneshot, Mutex as AsyncMutex , Notify } ;
2318use tonic:: async_trait;
2419
2520pub struct Listener {
2621 id : String ,
2722 s : Box < mpsc:: Sender < Option < server:: Call > > > ,
28- r : Arc < Mutex < mpsc:: Receiver < Option < server:: Call > > > > ,
23+ r : Arc < AsyncMutex < mpsc:: Receiver < Option < server:: Call > > > > ,
2924 // List of notifiers to call when closed.
30- closed_tx : Arc < std:: sync:: Mutex < Vec < oneshot:: Sender < Result < ( ) , String > > > > > ,
25+ #[ allow( clippy:: type_complexity) ]
26+ closed_tx : Arc < Mutex < Vec < oneshot:: Sender < Result < ( ) , String > > > > > ,
3127}
3228
3329static ID : AtomicU32 = AtomicU32 :: new ( 0 ) ;
@@ -38,8 +34,8 @@ impl Listener {
3834 let s = Arc :: new ( Self {
3935 id : format ! ( "{}" , ID . fetch_add( 1 , Ordering :: Relaxed ) ) ,
4036 s : Box :: new ( tx) ,
41- r : Arc :: new ( Mutex :: new ( rx) ) ,
42- closed_tx : Arc :: new ( std :: sync :: Mutex :: new ( Vec :: new ( ) ) ) ,
37+ r : Arc :: new ( AsyncMutex :: new ( rx) ) ,
38+ closed_tx : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
4339 } ) ;
4440 LISTENERS . lock ( ) . unwrap ( ) . insert ( s. id . clone ( ) , s. clone ( ) ) ;
4541 s
@@ -89,8 +85,7 @@ impl crate::server::Listener for Arc<Listener> {
8985 }
9086}
9187
92- static LISTENERS : LazyLock < std:: sync:: Mutex < HashMap < String , Arc < Listener > > > > =
93- LazyLock :: new ( std:: sync:: Mutex :: default) ;
88+ static LISTENERS : LazyLock < Mutex < HashMap < String , Arc < Listener > > > > = LazyLock :: new ( Mutex :: default) ;
9489
9590struct ClientTransport { }
9691
0 commit comments