2003-04-13 13:23:11 -04:00
|
|
|
;; From sunterlib
|
|
|
|
|
2003-04-13 13:36:39 -04:00
|
|
|
(define (with-lock* lock thunk)
|
2003-04-13 13:23:11 -04:00
|
|
|
(dynamic-wind
|
|
|
|
(lambda ()
|
|
|
|
(obtain-lock lock))
|
|
|
|
thunk
|
|
|
|
(lambda ()
|
|
|
|
(release-lock lock))))
|
|
|
|
|
2003-04-13 13:36:39 -04:00
|
|
|
(define-syntax with-lock
|
|
|
|
(syntax-rules ()
|
|
|
|
((with-lock lock body ...)
|
|
|
|
(with-lock* lock (lambda () body ...)))))
|
|
|
|
|