File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ //! todo
2+
3+ use std:: task:: { Context , Poll } ;
4+ use std:: sync:: { Arc , Mutex , Weak } ;
5+
6+ use tower_service:: Service ;
7+
8+
9+ /// todo
10+ pub struct Expire < S > {
11+ inner : Arc < Mutex < S > > ,
12+ }
13+
14+ /// todo
15+ pub struct Handle < S > {
16+ inner : Weak < Mutex < S > > ,
17+ }
18+
19+ // ===== impl Expire =====
20+
21+ impl < S , Req > Service < Req > for Expire < S >
22+ where
23+ S : Service < Req > ,
24+ {
25+ type Response = S :: Response ;
26+ type Error = S :: Error ;
27+ type Future = S :: Future ;
28+
29+ fn poll_ready ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
30+ self . inner . lock ( ) . unwrap ( ) . poll_ready ( cx)
31+ }
32+
33+ fn call ( & mut self , req : Req ) -> Self :: Future {
34+ self . inner . lock ( ) . unwrap ( ) . call ( req)
35+ }
36+ }
37+
38+
39+ // ===== impl Handle =====
40+
41+ impl < S > Handle < S > {
42+ pub async fn when < ' a , F > ( & self , fut : F ) -> Option < impl std:: ops:: DerefMut < Target = S > >
43+ where
44+ F : std:: future:: Future < Output = ( ) > ,
45+ {
46+ fut. await ;
47+ //Some(self.inner.upgrade()?.lock().unwrap())
48+ todo ! ( )
49+ }
50+ }
Original file line number Diff line number Diff line change 11//! Composable pool services
22
33pub mod cache;
4+ //pub mod expire;
45pub mod map;
56pub mod negotiate;
67pub mod singleton;
You can’t perform that action at this time.
0 commit comments