summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-02-28 10:45:21 +0100
committerAndy Wingo <wingo@pobox.com>2017-02-28 10:45:21 +0100
commit9e28a12121414b4b0508d56c9fe011d9059f48b7 (patch)
treeca3d592c638f5a5419a755aabb361bb0cb2b0d01 /module
parent70d4c4b284ba85d89969d8da43f80ff66f491e37 (diff)
Revert "futures: Limit the number of nested futures on the same stack."
This reverts commit 8a177d316c0062afe74f9a761ef460e297435e59, though keeping the additional tests. (Guile 2.2 doesn't have a fixed stack limit).
Diffstat (limited to 'module')
-rw-r--r--module/ice-9/futures.scm23
1 files changed, 7 insertions, 16 deletions
diff --git a/module/ice-9/futures.scm b/module/ice-9/futures.scm
index cc57e5c61..4a462839a 100644
--- a/module/ice-9/futures.scm
+++ b/module/ice-9/futures.scm
@@ -1,6 +1,6 @@
;;; -*- mode: scheme; coding: utf-8; -*-
;;;
-;;; Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+;;; Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
;;;
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public
@@ -90,14 +90,8 @@ touched."
;; A mapping of nested futures to futures waiting for them to complete.
(define %futures-waiting '())
-;; Nesting level of futures. Incremented each time a future is touched
-;; from within a future.
-(define %nesting-level (make-parameter 0))
-
-;; Maximum nesting level. The point is to avoid stack overflows when
-;; nested futures are executed on the same stack. See
-;; <http://bugs.gnu.org/13188>.
-(define %max-nesting-level 200)
+;; Whether currently running within a future.
+(define %within-future? (make-parameter #f))
(define-syntax-rule (with-mutex m e0 e1 ...)
;; Copied from (ice-9 threads) to avoid circular dependency.
@@ -153,8 +147,7 @@ adding it to the waiter queue."
(thunk (lambda ()
(call-with-prompt %future-prompt
(lambda ()
- (parameterize ((%nesting-level
- (1+ (%nesting-level))))
+ (parameterize ((%within-future? #t))
((future-thunk future))))
suspend))))
(set-future-result! future
@@ -253,16 +246,14 @@ adding it to the waiter queue."
(unlock-mutex (future-mutex future)))
((started)
(unlock-mutex (future-mutex future))
- (if (> (%nesting-level) 0)
+ (if (%within-future?)
(abort-to-prompt %future-prompt future)
(begin
(work)
(loop))))
- (else ; queued
+ (else
(unlock-mutex (future-mutex future))
- (if (> (%nesting-level) %max-nesting-level)
- (abort-to-prompt %future-prompt future)
- (work))
+ (work)
(loop))))
((future-result future)))