Megatest

Diff
Login

Differences From Artifact [693b1bc0fd]:

To Artifact [2795191c23]:


1
2
3
4
5
6

7

8


9
10
11
12


13


14
15
16
17
18
19
20
21
22









1
2
3
4
5

6
7
8

9
10
11
12
13
14
15
16

17
18
19
20
21
22





23
24
25
26
27
28
29
30
31





-
+

+
-
+
+




+
+
-
+
+




-
-
-
-
-
+
+
+
+
+
+
+
+
+


(define (make-cached-writer the-db)
  (let ((db    the-db)
	(queue '()))
    (lambda (cacheable . qry-params)
    (lambda (cacheable . qry-params) ;; fn qry
      (if cacheable
	  (begin
	  (set! queue (cons qry-params queue))
	    (set! queue (cons qry-params queue))
	    (call/cc))
	  (begin
	    (print "Starting transaction")
	    (for-each
	     (lambda (queue-item)
	       (let ((fn  (car queue-item))
		     (qry (cdr queue-item)))
	       (print "WRITE to " db ": " queue-item))
		 (print "WRITE to " db ": " qry)
		 )
	     (reverse queue))
	    (print "End transaction")
	    (print "READ from " db ": " qry-params))))))

(define a (make-cached-writer "the db"))
(a #t "insert abc")
(a #t "insert def")
(a #t "insert hij")
(a #f "select foo")
(define *cw* (make-cached-writer "the db"))

(define (dbcall cacheable query)
  (*cw* cacheable query))

(dbcall #t "insert abc")
(dbcall #t "insert def")
(dbcall #t "insert hij")
(dbcall #f "select foo")