about summary refs log blame commit diff stats
path: root/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/bad-serial.scm
blob: 1d6a486ae5a148c221d1668204f6cb1abc08ccfe (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                        
(define (make-serializer)
  (let ((in-use? #f))
    (lambda (proc)
      (define (protected-proc . args)
	(if in-use?
	    (begin
	     (wait-a-while)                 ; Never mind how to do that.
	     (apply protected-proc args))   ; Try again.
	    (begin
	     (set! in-use? #t)        ; Don't let anyone else in.
	     (apply proc args)        ; Call the original procedure.
	     (set! in-use? #f))))     ; Finished, let others in again.
      protected-proc)))