RecursionLock.st
branchjv
changeset 18027 3621469cc5e8
parent 18017 7fef9e17913f
parent 14779 4657463cd9f3
child 18079 7b5afc0ad3d5
--- a/RecursionLock.st	Thu Feb 07 09:53:25 2013 +0100
+++ b/RecursionLock.st	Tue Mar 05 18:10:13 2013 +0000
@@ -231,33 +231,7 @@
     "like critical:, but do not block if the lock cannot be aquired.
      Instead, return the value of the second argument, blockingBlock."
 
-    |active wasBlocked result|
-
-    active := Processor activeProcess.
-    "I already have the lock"
-    process == active ifTrue:[
-        ^ aBlock value
-    ].
-
-    wasBlocked := OperatingSystem blockInterrupts.
-
-    process notNil ifTrue:[
-        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-        ^ blockingBlock value
-    ].
-
-    [
-        process := active.
-        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-        result := aBlock value
-    ] ensure:[
-        process := nil.
-        sema signalIf.
-    ].
-    ^ result
-
-    "Created: / 08-06-2007 / 13:23:03 / cg"
-    "Modified: / 09-06-2007 / 14:22:47 / cg"
+    ^ self critical:aBlock timeoutMs:0 ifBlocking:blockingBlock.
 !
 
 critical:aBlock timeoutMs:timeoutMs ifBlocking:blockingBlock
@@ -290,6 +264,10 @@
     "/
     wasBlocked := OperatingSystem blockInterrupts.
     [
+        (process notNil and:[process isDead]) ifTrue:[
+            'RecursionLock [warning]: cleanup lock from dead process' infoPrintCR.
+            process := nil. sema signal.
+        ].
         gotSema := sema waitWithTimeoutMs:timeoutMs.
         gotSema notNil ifTrue:[
             process := active.
@@ -322,10 +300,10 @@
 !RecursionLock class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.37 2013-01-23 22:28:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.38 2013-02-08 21:13:20 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.37 2013-01-23 22:28:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.38 2013-02-08 21:13:20 stefan Exp $'
 ! !