--- a/RecursionLock.st Tue Oct 21 00:41:22 2014 +0200
+++ b/RecursionLock.st Tue Oct 21 21:19:55 2014 +0200
@@ -173,6 +173,22 @@
^ process notNil and:[Processor activeProcess ~~ process]
! !
+!RecursionLock methodsFor:'signaling'!
+
+signal
+ |wasBlocked|
+
+ process ~~ Processor activeProcess ifTrue:[
+ "I have already got the lock"
+ self error:'RecursionLock - signaling process doesn''t own the lock'.
+ ].
+
+ wasBlocked := OperatingSystem blockInterrupts.
+ process := nil.
+ sema signal.
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+! !
+
!RecursionLock methodsFor:'waiting'!
critical:aBlock
@@ -297,15 +313,39 @@
].
^ retVal.
+!
+
+wait
+ "wait, but do not block,
+ if this lock is already held by the current process.
+ Answer false, if alread locked, true if lock has been just acquired."
+
+ |active wasBlocked|
+
+ active := Processor activeProcess.
+ process == active ifTrue:[
+ "I have already got the lock"
+ ^ false.
+ ].
+
+ wasBlocked := OperatingSystem blockInterrupts.
+ (process notNil and:[process isDead]) ifTrue:[
+ 'RecursionLock [warning]: cleanup lock from dead process' infoPrintCR.
+ process := nil. sema signal.
+ ].
+ sema wait.
+ process := active.
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ true.
! !
!RecursionLock class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.40 2014-02-16 12:51:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.41 2014-10-21 19:19:55 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.40 2014-02-16 12:51:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.41 2014-10-21 19:19:55 stefan Exp $'
! !