Issue #94: simplified `RecursionLock >> #critical:` jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 28 Oct 2017 21:47:57 +0100
branchjv
changeset 23090 58f7ca7bb385
parent 23089 5022933af197
child 23091 817fd8c6e4c5
Issue #94: simplified `RecursionLock >> #critical:` Nore, that `#acquireWithTimeoutMs:` may never fail when timeout is nil (meaning wait indefinitely).
RecursionLock.st
--- a/RecursionLock.st	Mon Oct 09 00:08:34 2017 +0100
+++ b/RecursionLock.st	Sat Oct 28 21:47:57 2017 +0100
@@ -362,16 +362,12 @@
 
     <exception: #unwind>
 
-    | acquired retval |
+    | retval |
 
-    acquired := self acquireWithTimeoutMs: nil.
-    acquired == true ifTrue:[
-        retval := aBlock value
-    ].
+    self acquireWithTimeoutMs: nil.
+    retval := aBlock value.
     thisContext unmarkForUnwind.
-    acquired == true ifTrue:[
-        self release.
-    ].
+    self release.
     ^ retval
 
     "Created: / 31-08-2017 / 10:12:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -381,13 +377,7 @@
 
 unwindHandlerInContext:aContext
     aContext selector == #critical: ifTrue:[
-        | acquired |
-        acquired := aContext varAt: 1.
-        acquired == true ifTrue:[
-            ^ [ aContext varAt: 1 put: nil. self release ]
-        ] ifFalse:[
-            ^ nil.
-        ].
+        ^ [ self release ]
     ].
     self shouldNeverBeReached.