An exchanger is a procedure of one argument regulating mutually exclusive access to a resource. When a exchanger is called, its current content is returned, while being replaced by its argument in an atomic operation.
Returns a new exchanger with the argument obj as its initial content.(define queue (make-exchanger (list a)))
A queue implemented as an exchanger holding a list can be protected from reentrant execution thus:(define (pop queue) (let ((lst #f)) (dynamic-wind (lambda () (set! lst (queue #f))) (lambda () (and lst (not (null? lst)) (let ((ret (car lst))) (set! lst (cdr lst)) ret))) (lambda () (and lst (queue lst)))))) (pop queue) ⇒ a (pop queue) ⇒ #f
Returns an object of type arbiter and name name. Its state is initially unlocked.
#tand locks arbiter if arbiter was unlocked. Otherwise, returns