aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/srfi/srfi-41/util.scm15
-rw-r--r--module/vcomponent/search.scm4
2 files changed, 18 insertions, 1 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
diff --git a/module/vcomponent/search.scm b/module/vcomponent/search.scm
index 65e2630a..d240cbdc 100644
--- a/module/vcomponent/search.scm
+++ b/module/vcomponent/search.scm
@@ -63,7 +63,9 @@
;; Creates a prepared query wrappend in a paginator.
;; (event → bool), (stream event) → <paginator>
(define-public (prepare-query query-proc event-set)
- (make-paginator (stream-paginate (stream-filter query-proc event-set))))
+ (make-paginator (stream-paginate
+ (stream-timeslice-limit
+ (stream-filter query-proc event-set)))))
(define-record-type <paginator>
(make-paginator% query max-page true-max-page?)