From cf7fbccc90aec320c45cccde22856b373f8e08ff Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 12 Nov 2021 14:00:39 -0800 Subject: [PATCH] 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`. --- pollen/private/ts.rktd | 2 +- pollen/render.rkt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index cd148ef..6a36ec4 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1624459771 +1636754439 diff --git a/pollen/render.rkt b/pollen/render.rkt index 071ecb6..b3743e4 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -79,9 +79,14 @@ (define wp (place ch (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))) - (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)) ;; 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. @@ -137,7 +142,7 @@ (match jobs [(? null?) (loop null locks blocks completed-job-results completed-job-count)] [(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)])] [(list wpidx wp (and (or 'finished-job 'crashed-job) tag) source-path output-path ms) (match tag