Semaphore.st
changeset 3669 59baacaab0a8
parent 3609 f2ccf6a43330
child 3836 318f7d6f242b
--- a/Semaphore.st	Tue Jul 21 17:29:03 1998 +0200
+++ b/Semaphore.st	Tue Jul 21 17:45:49 1998 +0200
@@ -315,10 +315,12 @@
     |retVal gotSema|
 
     [
-	gotSema := self wait.
-	retVal := aBlock value.
+        gotSema := self wait.
+        retVal := aBlock value.
     ] valueOnUnwindDo:[
-	gotSema notNil ifTrue:[self signal].
+        "/ be careful - the unwind may occur both while waiting
+        "/ AND while evaluating the block.
+        gotSema notNil ifTrue:[self signal].
     ].
     self signal.
     ^ retVal
@@ -335,25 +337,26 @@
      coll := OrderedCollection new:10.
 
      [
-	1 to:1000 do:[:i |
-	    sema critical:[
-		coll addLast:i.
-		(Delay forSeconds:0.1) wait.
-	    ]
-	]
+        1 to:1000 do:[:i |
+            sema critical:[
+                coll addLast:i.
+                (Delay forSeconds:0.1) wait.
+            ]
+        ]
      ] forkAt:4.
 
      [
-	1 to:1000 do:[:i |
-	    sema critical:[
-		coll removeFirst.
-		(Delay forSeconds:0.1) wait.
-	    ]
-	]
+        1 to:1000 do:[:i |
+            sema critical:[
+                coll removeFirst.
+                (Delay forSeconds:0.1) wait.
+            ]
+        ]
      ] forkAt:4.
     "
 
-    "Modified: 16.4.1996 / 10:00:46 / stefan"
+    "Modified: / 16.4.1996 / 10:00:46 / stefan"
+    "Modified: / 21.7.1998 / 17:45:26 / cg"
 !
 
 signal
@@ -652,5 +655,5 @@
 !Semaphore class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.51 1998-06-18 14:08:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.52 1998-07-21 15:45:49 cg Exp $'
 ! !