@@ -89,7 +89,7 @@ impl<'a> Threaded<'a> {
89
89
}
90
90
91
91
impl < ' a > Executor for Threaded < ' a > {
92
- fn dispatch ( & mut self , item : Item ) -> Box < dyn ' _ + Iterator < Item = Item > > {
92
+ fn dispatch ( & mut self , item : Item ) -> Box < dyn Iterator < Item = Item > + ' _ > {
93
93
// Yield any completed work before accepting new work - keep memory
94
94
// pressure under control
95
95
// - return an iterator that runs until we can submit and then submits
@@ -100,7 +100,7 @@ impl<'a> Executor for Threaded<'a> {
100
100
} )
101
101
}
102
102
103
- fn join ( & mut self ) -> Box < dyn ' _ + Iterator < Item = Item > > {
103
+ fn join ( & mut self ) -> Box < dyn Iterator < Item = Item > + ' _ > {
104
104
// Some explanation is in order. Even though the tar we are reading from (if
105
105
// any) will have had its FileWithProgress download tracking
106
106
// completed before we hit drop, that is not true if we are unwinding due to a
@@ -115,16 +115,14 @@ impl<'a> Executor for Threaded<'a> {
115
115
// items, and the download tracker's progress is confounded with
116
116
// actual handling of data today, we synthesis a data buffer and
117
117
// pretend to have bytes to deliver.
118
- self . notify_handler
119
- . map ( |handler| handler ( Notification :: DownloadFinished ) ) ;
120
- self . notify_handler
121
- . map ( |handler| handler ( Notification :: DownloadPushUnits ( "iops" ) ) ) ;
122
118
let mut prev_files = self . n_files . load ( Ordering :: Relaxed ) ;
123
- self . notify_handler . map ( |handler| {
119
+ if let Some ( handler) = self . notify_handler {
120
+ handler ( Notification :: DownloadFinished ) ;
121
+ handler ( Notification :: DownloadPushUnits ( "iops" ) ) ;
124
122
handler ( Notification :: DownloadContentLengthReceived (
125
123
prev_files as u64 ,
126
- ) )
127
- } ) ;
124
+ ) ) ;
125
+ }
128
126
if prev_files > 50 {
129
127
println ! ( "{} deferred IO operations" , prev_files) ;
130
128
}
@@ -139,14 +137,15 @@ impl<'a> Executor for Threaded<'a> {
139
137
prev_files = current_files;
140
138
current_files = self . n_files . load ( Ordering :: Relaxed ) ;
141
139
let step_count = prev_files - current_files;
142
- self . notify_handler
143
- . map ( |handler| handler ( Notification :: DownloadDataReceived ( & buf[ 0 ..step_count] ) ) ) ;
140
+ if let Some ( handler) = self . notify_handler {
141
+ handler ( Notification :: DownloadDataReceived ( & buf[ 0 ..step_count] ) ) ;
142
+ }
144
143
}
145
144
self . pool . join ( ) ;
146
- self . notify_handler
147
- . map ( | handler| handler ( Notification :: DownloadFinished ) ) ;
148
- self . notify_handler
149
- . map ( |handler| handler ( Notification :: DownloadPopUnits ) ) ;
145
+ if let Some ( handler ) = self . notify_handler {
146
+ handler ( Notification :: DownloadFinished ) ;
147
+ handler ( Notification :: DownloadPopUnits ) ;
148
+ }
150
149
// close the feedback channel so that blocking reads on it can
151
150
// complete. send is atomic, and we know the threads completed from the
152
151
// pool join, so this is race-free. It is possible that try_iter is safe
@@ -167,7 +166,7 @@ impl<'a> Executor for Threaded<'a> {
167
166
} )
168
167
}
169
168
170
- fn completed ( & mut self ) -> Box < dyn ' _ + Iterator < Item = Item > > {
169
+ fn completed ( & mut self ) -> Box < dyn Iterator < Item = Item > + ' _ > {
171
170
Box :: new ( JoinIterator {
172
171
iter : self . rx . try_iter ( ) ,
173
172
consume_sentinel : true ,
0 commit comments