diff options
author | Ludovic Courtès <ludo@gnu.org> | 2010-12-16 23:44:55 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2010-12-16 23:45:24 +0100 |
commit | c21a5ddcaf2b17d65355c977f37ee50375961d17 (patch) | |
tree | 71998282b4cb2ba68dfb71ce0bf12d68e18dfc60 /doc/ref/api-scheduling.texi | |
parent | 6c17f7bd7147c613fc2c5ddad3e3139defdb55e7 (diff) | |
download | guile-c21a5ddcaf2b17d65355c977f37ee50375961d17.tar.gz |
Implement `(ice-9 threads)' high-level constructs in terms of futures.
* module/ice-9/threads.scm (parallel, par-mapper): Rewrite in terms of
`future' and `touch'.
* test-suite/tests/threads.test ("par-map", "par-for-each"): New test
prefixes.
* doc/ref/api-scheduling.texi (Parallel Forms): Add cross-ref to
futures. Recommend against the `n-' variants.
Diffstat (limited to 'doc/ref/api-scheduling.texi')
-rw-r--r-- | doc/ref/api-scheduling.texi | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi index d202f4a69..d5504168c 100644 --- a/doc/ref/api-scheduling.texi +++ b/doc/ref/api-scheduling.texi @@ -904,6 +904,11 @@ The functions described in this section are available from (use-modules (ice-9 threads)) @end example +They provide high-level parallel constructs. The following functions +are implemented in terms of futures (@pxref{Futures}). Thus they are +relatively cheap as they re-use existing threads, and portable, since +they automatically use one thread per available CPU core. + @deffn syntax parallel expr1 @dots{} exprN Evaluate each @var{expr} expression in parallel, each in its own thread. Return the results as a set of @var{N} multiple values @@ -935,6 +940,16 @@ These functions are like @code{map} and @code{for-each} (@pxref{List Mapping}), but make their @var{proc} calls in parallel. @end deffn +Unlike those above, the functions described below take a number of +threads as an argument. This makes them inherently non-portable since +the specified number of threads may differ from the number of available +CPU cores as returned by @code{current-processor-count} +(@pxref{Processes}). In addition, these functions create the specified +number of threads when they are called and terminate them upon +completion, which makes them quite expensive. + +Therefore, they should be avoided. + @deffn {Scheme Procedure} n-par-map n proc lst1 @dots{} lstN @deffnx {Scheme Procedure} n-par-for-each n proc lst1 @dots{} lstN Call @var{proc} on the elements of the given lists, in the same way as |