Simplify blocking-box's manager

This commit is contained in:
Tony Garnock-Jones 2011-11-23 15:50:56 -05:00
parent 9cf5deadeb
commit faeb19a27e
2 changed files with 12 additions and 2 deletions

View File

@ -19,8 +19,8 @@
(define (manager s g)
(define v (channel-get s))
(let loop ()
(sync (handle-evt s (lambda (ignored-new-v) (loop)))
(handle-evt (channel-put-evt g v) (lambda (dummy) (loop))))))
(sync s (channel-put-evt g v)) ;; ignore any future settings, answer all future gettings
(loop)))
(define (blocking-box-evt b)
(guard-evt

10
test-blocking-box.rkt Normal file
View File

@ -0,0 +1,10 @@
#lang racket/base
(require "blocking-box.rkt")
(require rackunit)
(define b (make-blocking-box))
(set-blocking-box! b 1)
(set-blocking-box! b 2)
(set-blocking-box! b 3)
(check-equal? (blocking-box-value b) 1)