|
162 | 162 | (intern (string-upcase project)))) |
163 | 163 |
|
164 | 164 |
|
165 | | -(defun call-with-skipping (fun &key (stream *standard-output*)) |
166 | | - (handler-bind ((error (lambda (condition) |
167 | | - (when (find-restart 'skip) |
168 | | - (when (boundp '*current-mapped-source*) |
169 | | - (format stream "~&* ~A~%" *current-mapped-source*) |
170 | | - (format stream ":: from ~A~%" |
171 | | - (find-source *current-mapped-source*))) |
172 | | - (format stream "~&SKIPPING (~A)~%" condition) |
173 | | - (invoke-restart 'skip))))) |
174 | | - (funcall fun))) |
175 | | - |
176 | | -(defun update-what-you-can (&optional file) |
| 165 | +(defvar *output-lock* (bt:make-lock "output-lock")) |
| 166 | + |
| 167 | +(defun call-with-skipping (fun &key (stream *standard-output*) parallel) |
| 168 | + (flet ((invoke-skip (condition) |
| 169 | + (when (find-restart 'skip) |
| 170 | + (bt:with-lock-held (*output-lock*) |
| 171 | + (when (boundp '*current-mapped-source*) |
| 172 | + (format stream "~&* ~A~%" *current-mapped-source*) |
| 173 | + (format stream ":: from ~A~%" |
| 174 | + (find-source *current-mapped-source*))) |
| 175 | + (format stream "~&SKIPPING (~A)~%" condition)) |
| 176 | + (invoke-restart 'skip)))) |
| 177 | + (if (not parallel) |
| 178 | + (handler-bind ((error #'invoke-skip)) |
| 179 | + (funcall fun)) |
| 180 | + (lparallel:task-handler-bind ((error #'invoke-skip)) |
| 181 | + (funcall fun))))) |
| 182 | + |
| 183 | +(defun update-what-you-can (&optional file parallel) |
177 | 184 | (flet ((action (stream) |
178 | 185 | (call-with-skipping |
179 | 186 | (lambda () |
180 | | - (pmap-sources (lambda (source) |
181 | | - (force-output stream) |
182 | | - (format t "~&Updating ~S from ~A~%" |
183 | | - (project-name source) |
184 | | - (location source)) |
185 | | - (update-source-cache source)))) |
186 | | - :stream stream))) |
| 187 | + (funcall (if parallel 'pmap-sources 'map-sources) |
| 188 | + (lambda (source) |
| 189 | + (bt:with-lock-held (*output-lock*) |
| 190 | + (force-output stream) |
| 191 | + (format t "~&Updating ~S from ~A~%" |
| 192 | + (project-name source) |
| 193 | + (location source))) |
| 194 | + (update-source-cache source)))) |
| 195 | + :stream stream |
| 196 | + :parallel parallel))) |
187 | 197 | (if file |
188 | 198 | (with-open-file (stream file :direction :output |
189 | | - :if-exists :rename-and-delete) |
| 199 | + :if-exists :rename-and-delete) |
190 | 200 | (action (make-broadcast-stream *standard-output* stream))) |
191 | 201 | (action *standard-output*)))) |
192 | 202 |
|
|
0 commit comments