--- a/RecursionLock.st Tue May 09 02:08:35 1995 +0200
+++ b/RecursionLock.st Tue May 09 02:17:53 1995 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -26,18 +26,20 @@
"
like a Semaphore for mutual exclusion, but avoids the deadlock
if a critical region is reentered by the same process again.
+ I.e. allows reentering the critical region if the current process
+ is the one which did the original locking.
example:
- |lock|
+ |lock|
- lock := RecursionLock new.
- lock critical:[
- Transcript showCr:'in lock ...'.
- lock critical:[
- Transcript showCr:'again ...'
- ]
- ]
+ lock := RecursionLock new.
+ lock critical:[
+ Transcript showCr:'in lock ...'.
+ lock critical:[
+ Transcript showCr:'again ...'
+ ]
+ ]
"
!
@@ -45,7 +47,7 @@
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -59,7 +61,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.1 1995-05-01 23:03:08 claus Exp $
+$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.2 1995-05-09 00:17:53 claus Exp $
"
! !
@@ -80,14 +82,16 @@
active := Processor activeProcess.
process == active ifTrue:[
- aBlock value
+ aBlock value
] ifFalse:[
- process := active.
- [
- sema critical:aBlock
- ] valueNowOrOnUnwindDo:[
- process := nil
- ]
+ [
+ sema critical:[
+ process := active.
+ aBlock value
+ ]
+ ] valueNowOrOnUnwindDo:[
+ process := nil
+ ]
].
! !
@@ -96,4 +100,3 @@
initialize
sema := Semaphore forMutualExclusion
! !
-