Future.st
changeset 1514 83af7e61d415
parent 1327 cf928a994f81
child 1516 08829dfb29fe
--- a/Future.st	Tue Jan 25 12:04:36 2005 +0100
+++ b/Future.st	Wed Jan 26 14:41:37 2005 +0100
@@ -154,84 +154,85 @@
 "
 ! !
 
-!Future class methodsFor:'class initialization'!
-
-initialize
-	"must avoid the checks"
-
-	superclass := nil
-
-	"Future initialize."
-! !
-
 !Future methodsFor:'evaluating'!
 
 block: aBlock
-	"Execute aBlock in parallel with whatever called me, but
-	 ensure that any messages sent to me before execution
-	 of the block has terminated are suspended until it has terminated."
+    "Execute aBlock in parallel with whatever called me, but
+     ensure that any messages sent to me before execution
+     of the block has terminated are suspended until it has terminated."
 
-	semaphore := Semaphore new.
-	[result := aBlock value.  semaphore signal] fork
+    semaphore := Semaphore new name:'Future'.
+    [result := aBlock ensure:[semaphore signal]] fork
 !
 
 block: aBlock value: aValue
-	"Execute aBlock in parallel with whatever called me, but
-	 ensure that any messages sent to me before execution
-	 of the block has terminated are suspended until it has terminated."
+    "Execute aBlock in parallel with whatever called me, but
+     ensure that any messages sent to me before execution
+     of the block has terminated are suspended until it has terminated."
 
-	semaphore := Semaphore new.
-	[result := aBlock value: aValue.  semaphore signal] fork
+    semaphore := Semaphore new name:'Future'.
+    [
+        result := [
+            aBlock value:aValue
+        ] ensure:[semaphore signal]
+    ] fork
 !
 
 block: aBlock value: value1 value: value2
-	"Execute aBlock in parallel with whatever called me, but
-	 ensure that any messages sent to me before execution
-	 of the block has terminated are suspended until it has terminated."
+    "Execute aBlock in parallel with whatever called me, but
+     ensure that any messages sent to me before execution
+     of the block has terminated are suspended until it has terminated."
 
-	semaphore := Semaphore new.
-	[result := aBlock value: value1 value: value2.
-	 semaphore signal] fork
+    semaphore := Semaphore new name:'Future'.
+    [
+        result := [
+            aBlock value: value1 value: value2
+        ] ensure:[semaphore signal]
+    ] fork
 !
 
 block: aBlock value: value1 value: value2 value: value3
-	"Execute aBlock in parallel with whatever called me, but
-	 ensure that any messages sent to me before execution
-	 of the block has terminated are suspended until it has terminated."
+    "Execute aBlock in parallel with whatever called me, but
+     ensure that any messages sent to me before execution
+     of the block has terminated are suspended until it has terminated."
 
-	semaphore := Semaphore new.
-	[result := aBlock value: value1 value: value2 value: value3.
-	 semaphore signal] fork
+    semaphore := Semaphore new name:'Future'.
+    [
+        result := [
+            aBlock value: value1 value: value2 value: value3
+        ] ensure:[semaphore signal]
+    ] fork
 !
 
 block: aBlock valueWithArguments: anArray
-	"Execute aBlock in parallel with whatever called me, but
-	 ensure that any messages sent to me before execution
-	 of the block has terminated are suspended until it has terminated."
+    "Execute aBlock in parallel with whatever called me, but
+     ensure that any messages sent to me before execution
+     of the block has terminated are suspended until it has terminated."
 
-	semaphore := Semaphore new.
-	[result := aBlock valueWithArguments: anArray.
-	 semaphore signal] fork
+    semaphore := Semaphore new name:'Future'.
+    [
+        result := [
+            aBlock valueWithArguments: anArray
+        ] ensure:[semaphore signal]
+    ] fork
 ! !
 
 !Future methodsFor:'synchronising'!
 
-doesNotUnderstand: aMessage
-        "Any message to a Future will end up here."
-
-        semaphore waitUncounted.     "Wait for evaluation to complete"
-                                    "(if not already completed)"
-
-        ^result perform: aMessage selector 
-                withArguments: aMessage arguments
-!
-
-hasValue
-        ^ semaphore wouldBlock not
+doesNotUnderstand:aMessage 
+    "Any message to a Future will end up here."
+    
+    semaphore waitUncounted. "Wait for evaluation to complete"
+                             "(if not already completed)" 
+    ^ result perform:aMessage selector withArguments:aMessage arguments
 ! !
 
 !Future methodsFor:'testing'!
 
+hasValue
+    ^ semaphore wouldBlock not
+!
+
 isLazyValue
     ^ semaphore wouldBlock
 ! !
@@ -239,7 +240,5 @@
 !Future class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.8 2003-10-10 16:34:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.9 2005-01-26 13:41:37 stefan Exp $'
 ! !
-
-Future initialize!