Blob


1 (define x 10)
2 (define s (make-serializer))
3 (parallel-execute (s (lambda () (set! x (* x x))))
4 (s (lambda () (set! x (+ x 1)))))
6 (define (make-account balance)
7 (define (withdraw amount)
8 (if (>= balance amount)
9 (begin (set! balance (- balance amount))
10 balance)
11 "Insufficient funds"))
12 (define (deposit amount)
13 (set! balance (+ balance amount))
14 balance)
15 (let ((protected (make-serializer)))
16 (define (dispatch m)
17 (cond ((eq? m 'withdraw) (protected withdraw))
18 ((eq? m 'deposit) (protected deposit))
19 (else (error "Unknown request -- MAKE-ACCOUT" m))))
20 dispatch))