aboutsummaryrefslogtreecommitdiff
path: root/module
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
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')
-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?)