From 2e5fd56011f449383438b22050715904a1147d79 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Fri, 7 Dec 2001 11:28:37 +0000 Subject: [PATCH] Minor clean-up. --- scsh/scsh.scm | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/scsh/scsh.scm b/scsh/scsh.scm index ee1f30a..7a48e93 100644 --- a/scsh/scsh.scm +++ b/scsh/scsh.scm @@ -115,14 +115,13 @@ ;;; Should be moved to somewhere else (define (with-lock lock thunk) - (with-handler (lambda (condition more) - (release-lock lock) - (more)) - (lambda () - (obtain-lock lock) - (let ((result (thunk))) - (release-lock lock) - result)))) + (dynamic-wind + (lambda () + (release-lock lock)) + thunk + (lambda () + (release-lock lock)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -169,11 +168,6 @@ (process-set-resource dir) (set! *resource-cache* (process-read-resource))) - ;; Dynamic-wind is not the right thing to take care of the lock; - ;; it would release the lock on every context switch. - ;; With-lock releases the lock on a condition, using call/cc will - ;; skrew things up - ;; The thread-specific resource: A thread fluid (define $resource 'empty-resource-value) @@ -183,8 +177,8 @@ (define (let-resource dir thunk) (let-thread-fluid $resource dir thunk)) - (define (with-resource* dir thunk) - (let ((changed-dir #f)) ; TODO 0.5 used to have a dynamic-wind here!!! + (define (with-resource* dir thunk) + (let ((changed-dir #f)) (with-lock resource-lock (lambda () (change-and-cache dir)