Reported by David Pirotte.
* module/ice-9/futures.scm (process-futures): Wait on %FUTURES-AVAILABLE
only when %FUTURES is empty.
The problem was obvious when running (begin (use-modules (ice-9
threads)) (par-map 1+ (iota 400000))) : eventually, only the main
thread would do the work, while the others would remain idle, waiting
on %FUTURES-AVAILABLE.
;; Wait for futures to be available and process them.
(lock-mutex %futures-mutex)
(let loop ()
- (wait-condition-variable %futures-available
- %futures-mutex)
+ (when (q-empty? %futures)
+ (wait-condition-variable %futures-available
+ %futures-mutex))
+
(or (q-empty? %futures)
(let ((future (deq! %futures)))
(lock-mutex (future-mutex future))