mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
futures: Have workers work when futures are available.
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.
This commit is contained in:
parent
1d4e6ee301
commit
134c95f1e6
1 changed files with 4 additions and 2 deletions
|
@ -93,8 +93,10 @@ touched."
|
|||
;; 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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue