From d7241d6fe8b151f6d15db9cac8fba44b074ca215 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 16 Nov 2014 18:52:58 +0000 Subject: [PATCH] Remove support for recursion in WITH-THREAD-MUTEX-LOCKED. --- src/runtime/thread.scm | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/src/runtime/thread.scm b/src/runtime/thread.scm index b51714148..c9c766ffd 100644 --- a/src/runtime/thread.scm +++ b/src/runtime/thread.scm @@ -1104,41 +1104,15 @@ USA. (define (with-thread-mutex-locked mutex thunk) (guarantee-thread-mutex mutex 'WITH-THREAD-MUTEX-LOCKED) - (let ((thread (current-thread)) - (grabbed-lock?)) - (dynamic-wind - (lambda () - (let ((owner (thread-mutex/owner mutex))) - (if (eq? owner thread) - (begin - (set! grabbed-lock? #f) - unspecific) - (begin - (set! grabbed-lock? #t) - (%lock-thread-mutex mutex thread owner))))) - thunk - (lambda () - (if (and grabbed-lock? (eq? (thread-mutex/owner mutex) thread)) - (%unlock-thread-mutex mutex thread)))))) + (dynamic-wind (lambda () (lock-thread-mutex mutex)) + thunk + (lambda () (unlock-thread-mutex mutex)))) (define (with-thread-mutex-unlocked mutex thunk) (guarantee-thread-mutex mutex 'WITH-THREAD-MUTEX-UNLOCKED) - (let ((thread (current-thread)) - (released-lock?)) - (dynamic-wind - (lambda () - (let ((owner (thread-mutex/owner mutex))) - (if (not (eq? owner thread)) - (set! released-lock? #f) - (begin - (set! released-lock? #t) - (%unlock-thread-mutex mutex owner))))) - thunk - (lambda () - (if released-lock? - (let ((owner (thread-mutex/owner mutex))) - (if (not (eq? owner thread)) - (%lock-thread-mutex mutex thread owner)))))))) + (dynamic-wind (lambda () (unlock-thread-mutex mutex)) + thunk + (lambda () (lock-thread-mutex mutex)))) (define (%disassociate-thread-mutexes thread) (do ((mutexes (thread/mutexes thread) (cdr mutexes))) -- 2.25.1