File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,24 @@ use tokio::task::JoinError;
88/// This enables a parent task to await all children simultaneously but still
99/// determine what child has exited for logging/diagnosis purposes.
1010#[ derive( Debug ) ]
11- pub struct NamedTask < Ret = ( ) , Id = String >
11+ pub struct NamedTask < Ret = ( ) , Name = String >
1212where
13- Id : Clone + Unpin ,
13+ Name : Clone + Unpin ,
1414{
1515 task : Pin < Box < tokio:: task:: JoinHandle < Ret > > > ,
16- id : Id ,
16+ name : Name ,
1717}
1818
19- impl < R , I > NamedTask < R , I >
19+ impl < Ret , Name > NamedTask < Ret , Name >
2020where
21- I : Clone + Unpin ,
21+ Name : Clone + Unpin ,
2222{
23- pub fn new ( task : tokio:: task:: JoinHandle < R > , id : I ) -> Self {
24- NamedTask { task : Box :: pin ( task) , id }
23+ pub fn new ( task : tokio:: task:: JoinHandle < Ret > , name : Name ) -> Self {
24+ NamedTask { task : Box :: pin ( task) , name }
25+ }
26+
27+ pub fn name ( & self ) -> & Name {
28+ & self . name
2529 }
2630}
2731
3539 mut self : Pin < & mut Self > ,
3640 cx : & mut std:: task:: Context < ' _ > ,
3741 ) -> std:: task:: Poll < Self :: Output > {
38- self . task . as_mut ( ) . poll ( cx) . map ( |v| ( self . id . clone ( ) , v) )
42+ self . task . as_mut ( ) . poll ( cx) . map ( |v| ( self . name . clone ( ) , v) )
3943 }
4044}
You can’t perform that action at this time.
0 commit comments