aboutsummaryrefslogtreecommitdiff
path: root/module/srfi
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 10:47:34 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 10:47:34 +0200
commit60d2623efc54eb38d8f4e087f39b32bee4e1aee8 (patch)
tree2a02cefda0823591392f7da306c4be63bd718e1b /module/srfi
parentPartial search page works, but alway times out first. (diff)
downloadcalp-60d2623efc54eb38d8f4e087f39b32bee4e1aee8.tar.gz
calp-60d2623efc54eb38d8f4e087f39b32bee4e1aee8.tar.xz
Add stream-timeslice-limit.
Diffstat (limited to 'module/srfi')
-rw-r--r--module/srfi/srfi-41/util.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm
index 472170d7..a6c6dc3d 100644
--- a/module/srfi/srfi-41/util.scm
+++ b/module/srfi/srfi-41/util.scm
@@ -102,6 +102,21 @@
(define*-public (stream-paginate stream optional: (page-size 10))
(stream-paginate% stream page-size))
+
+(define (eager-stream-cons a b)
+ (stream-cons a b))
+
+(use-modules (ice-9 sandbox) )
+(define (stream-timeslice-limit strm)
+ (call-with-time-limit
+ 0.1
+ (lambda () (eager-stream-cons
+ (stream-car strm)
+ (stream-timeslice-limit (stream-cdr strm))))
+ (lambda _ stream-null)))
+
+(export stream-timeslice-limit)
+
;; Evaluates @var{body} in a context where most list fundamentals are
;; replaced by stream alternatives.
;; commented defifinitions are items which could be included, but for