summaryrefslogtreecommitdiff
path: root/doc/ref/api-scheduling.texi
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-03-27 18:03:47 +0100
committerLudovic Courtès <ludo@gnu.org>2013-03-27 18:09:49 +0100
commit8a177d316c0062afe74f9a761ef460e297435e59 (patch)
tree8cba3ce3b9440946a7b294a1a873b602a712ede0 /doc/ref/api-scheduling.texi
parent8cd109bf0a10e37c26bf476fed81a0d4282d13c6 (diff)
downloadguile-8a177d316c0062afe74f9a761ef460e297435e59.tar.gz
futures: Limit the number of nested futures on the same stack.
Fixes <http://bugs.gnu.org/13188>. Reported by Nala Ginrut <nalaginrut@gmail.com>. * module/ice-9/futures.scm (%nesting-level): Rename to... (%nesting-level): ... this. Default to 0 instead of #f. Update users. (%max-nesting-level): New variable. (touch): When FUTURE is queued and (%nesting-level) is above %MAX-NESTING-LEVEL, abort to %FUTURE-PROMPT. * test-suite/tests/future.test ("nested futures")["loop"]: Remove `compile' call. * test-suite/tests/threads.test ("par-map")["long list"]: New test. * doc/ref/api-scheduling.texi (Futures): Add a paragraph about stack consumption.
Diffstat (limited to 'doc/ref/api-scheduling.texi')
-rw-r--r--doc/ref/api-scheduling.texi7
1 files changed, 7 insertions, 0 deletions
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index e040904cf..b23082192 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -1037,6 +1037,13 @@ future has completed. This suspend/resume is achieved by capturing the
calling future's continuation, and later reinstating it (@pxref{Prompts,
delimited continuations}).
+Note that @code{par-map} above is not tail-recursive. This could lead
+to stack overflows when @var{lst} is large compared to
+@code{(current-processor-count)}. To address that, @code{touch} uses
+the suspend mechanism described above to limit the number of nested
+futures executing on the same stack. Thus, the above code should never
+run into stack overflows.
+
@deffn {Scheme Syntax} future exp
Return a future for expression @var{exp}. This is equivalent to: