manually propagate `current-project-root` to parallel threads

When recursive mode is used, `current-project-root` changes during the extent of a render operation. But if parallel rendering is also used, when the main thread re-parameterizes `current-project-root`, it will have no effect on the parallel threads, because they freshly instantiate `current-project-root` (with its default value). This patch moves the parameterization inside the parallel thread by passing the `current-project-root` value as part of the job message, thereby handling it the same way as `current-poly-target`.
pull/263/head
Matthew Butterick 3 years ago
parent ec4da2e679
commit cf7fbccc90

@ -1 +1 @@
1624459771 1636754439

@ -79,9 +79,14 @@
(define wp (define wp
(place ch (place ch
(let loop () (let loop ()
(match-define (list source-path output-path poly-target) (match-define (list project-root source-path output-path poly-target)
(place-channel-put/get ch (list 'wants-job))) (place-channel-put/get ch (list 'wants-job)))
(parameterize ([current-poly-target poly-target]) ;; we manually propagate our parameter values for
;; current-project-root and current-poly-target
;; because parameter values are not automatically shared
;; between parallel threads.
(parameterize ([current-project-root project-root]
[current-poly-target poly-target])
(place-channel-put/get ch (list 'wants-lock output-path)) (place-channel-put/get ch (list 'wants-lock output-path))
;; trap any exceptions and pass them back as crashed jobs. ;; trap any exceptions and pass them back as crashed jobs.
;; otherwise, a crashed rendering place can't recover, and the parallel job will be stuck. ;; otherwise, a crashed rendering place can't recover, and the parallel job will be stuck.
@ -137,7 +142,7 @@
(match jobs (match jobs
[(? null?) (loop null locks blocks completed-job-results completed-job-count)] [(? null?) (loop null locks blocks completed-job-results completed-job-count)]
[(cons ($job source-path output-path) rest) [(cons ($job source-path output-path) rest)
(place-channel-put wp (list source-path output-path poly-target)) (place-channel-put wp (list (current-project-root) source-path output-path poly-target))
(loop rest locks blocks completed-job-results completed-job-count)])] (loop rest locks blocks completed-job-results completed-job-count)])]
[(list wpidx wp (and (or 'finished-job 'crashed-job) tag) source-path output-path ms) [(list wpidx wp (and (or 'finished-job 'crashed-job) tag) source-path output-path ms)
(match tag (match tag

Loading…
Cancel
Save