@@ -115,16 +115,18 @@ 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" ) ) ) ;
118
+ if let Some ( handler) = self . notify_handler {
119
+ handler ( Notification :: DownloadFinished ) ;
120
+ }
121
+ if let Some ( handler) = self . notify_handler {
122
+ handler ( Notification :: DownloadPushUnits ( "iops" ) ) ;
123
+ }
122
124
let mut prev_files = self . n_files . load ( Ordering :: Relaxed ) ;
123
- self . notify_handler . map ( |handler| {
125
+ if let Some ( handler ) = self . notify_handler {
124
126
handler ( Notification :: DownloadContentLengthReceived (
125
127
prev_files as u64 ,
126
- ) )
127
- } ) ;
128
+ ) ) ;
129
+ }
128
130
if prev_files > 50 {
129
131
println ! ( "{} deferred IO operations" , prev_files) ;
130
132
}
@@ -139,14 +141,17 @@ impl<'a> Executor for Threaded<'a> {
139
141
prev_files = current_files;
140
142
current_files = self . n_files . load ( Ordering :: Relaxed ) ;
141
143
let step_count = prev_files - current_files;
142
- self . notify_handler
143
- . map ( |handler| handler ( Notification :: DownloadDataReceived ( & buf[ 0 ..step_count] ) ) ) ;
144
+ if let Some ( handler) = self . notify_handler {
145
+ handler ( Notification :: DownloadDataReceived ( & buf[ 0 ..step_count] ) ) ;
146
+ }
144
147
}
145
148
self . pool . join ( ) ;
146
- self . notify_handler
147
- . map ( |handler| handler ( Notification :: DownloadFinished ) ) ;
148
- self . notify_handler
149
- . map ( |handler| handler ( Notification :: DownloadPopUnits ) ) ;
149
+ if let Some ( handler) = self . notify_handler {
150
+ handler ( Notification :: DownloadFinished ) ;
151
+ }
152
+ if let Some ( handler) = self . notify_handler {
153
+ handler ( Notification :: DownloadPopUnits ) ;
154
+ }
150
155
// close the feedback channel so that blocking reads on it can
151
156
// complete. send is atomic, and we know the threads completed from the
152
157
// pool join, so this is race-free. It is possible that try_iter is safe
0 commit comments