added #hasValue rel4_1_7 release
authorClaus Gittinger <cg@exept.de>
Sun, 02 Feb 2003 18:19:44 +0100
changeset 1140 cbb20fd710fa
parent 1139 aea281a4e983
child 1141 f3e59ead8610
added #hasValue
Future.st
--- a/Future.st	Wed Jan 29 20:42:13 2003 +0100
+++ b/Future.st	Sun Feb 02 18:19:44 2003 +0100
@@ -1,45 +1,36 @@
+"
+ This is a Manchester Goodie protected by copyright.
+ These conditions are imposed on the whole Goodie, and on any significant
+ part of it which is separately transmitted or stored:
+	* You must ensure that every copy includes this notice, and that
+	  source and author(s) of the material are acknowledged.
+	* These conditions must be imposed on anyone who receives a copy.
+	* The material shall not be used for commercial gain without the prior
+	  written consent of the author(s).
+ Further information on the copyright conditions may be obtained by
+ sending electronic mail:
+	To: goodies-lib@cs.man.ac.uk
+	Subject: copyright
+ or by writing to The Smalltalk Goodies Library Manager, Dept of
+ Computer Science, The University, Manchester M13 9PL, UK
+
+ (C) Copyright 1992 University of Manchester
+ For more information about the Manchester Goodies Library (from which 
+ this file was distributed) send e-mail:
+	To: goodies-lib@cs.man.ac.uk
+	Subject: help 
+"
+
 "{ Package: 'stx:goodies' }"
 
-"       NAME            Parallelism
-	AUTHOR          tph@cs.man.ac.uk
-	FUNCTION throttled Futures; lazy eval; explicit pa'l'l procs 
-	ST-VERSIONS     stx
-	PREREQUISITES    
-	CONFLICTS       
-	DISTRIBUTION    world
-	VERSION         1.1
-	DATE    22 Jan 1989
-	SUMMARY 
-Parallelism contains a number of explicitly parallel constructs,
-including a new version of Future, Lazy evaluation, and explicit
-parallel processes.  Lots of code in here.  Contains an early
-version (read: doesn't work) of a ""throttled"" future mechanism.
-New version RSN.(2.2).TPH
-
-claus: I have separated the original Parallelism package into
-       individual ones: Lazy, Future, ThrottledFuture and ParallelEvaluation
-"!
-
-'From Smalltalk-80, version 2, of April 1, 1983 on 29 March 1987 at 5:13:27 pm'!
-
-!Object methodsFor: 'parallel evaluation'!
-
-touch
-	"Simply returns self.  If the receiver is an uncompleted
-	 Future or Lazy, this forces complete evaluation."
-
-	^self
-! !
-
-Object subclass: #Future
-	instanceVariableNames: 'result semaphore '
-	classVariableNames: ''
-	poolDictionaries: ''
-	category: 'Kernel-Processes'
+nil subclass:#Future
+	instanceVariableNames:'result semaphore'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Kernel-Processes'
 !
 
-Future comment:
-'I represent an execution in progress.  Any messages sent to me are delayed until
+Future comment:'I represent an execution in progress.  Any messages sent to me are delayed until
  execution has completed.'
 !
 
@@ -161,25 +152,19 @@
 	v contents:text
 								    [exEnd]
 "
-!
-
-version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.6 2000-03-02 14:14:58 cg Exp $'
 ! !
 
-!Future methodsFor: 'synchronising'!
-
-doesNotUnderstand: aMessage
-	"Any message to a Future will end up here."
+!Future class methodsFor:'class initialization'!
 
-	semaphore wait.     "Wait for evaluation to complete"
-			    "(if not already completed)"
-	semaphore signal.   "Wake up anything else that might be waiting"
-	^result perform: aMessage selector 
-		withArguments: aMessage arguments
+initialize
+	"must avoid the checks"
+
+	superclass := nil
+
+	"Future initialize."
 ! !
 
-!Future methodsFor: 'evaluating'!
+!Future methodsFor:'evaluating'!
 
 block: aBlock
 	"Execute aBlock in parallel with whatever called me, but
@@ -229,123 +214,26 @@
 	 semaphore signal] fork
 ! !
 
-!Future class methodsFor: 'class initialization'!
+!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)"
 
-initialize
-	"must avoid the checks"
+        ^result perform: aMessage selector 
+                withArguments: aMessage arguments
+!
 
-	superclass := nil
+hasValue
+        ^ semaphore wouldBlock not
+! !
 
-	"Future initialize."
+!Future class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.7 2003-02-02 17:19:44 cg Exp $'
 ! !
 
 Future initialize!
-
-!Block methodsFor: 'parallel evaluation'!
-
-futureValue
-	"Fork a synchronised evaluation of myself. Starts the
-	 evaluation in parallel immediately."
-
-	^Future new block: self
-!
-
-futureValue: aValue
-	"Fork a synchronised evaluation of myself. Starts the
-	 evaluation in parallel immediately."
-
-	^Future new block: self value: aValue
-!
-
-futureValue: aValue value: anotherValue
-	"Fork a synchronised evaluation of myself. Starts the
-	 evaluation in parallel immediately."
-
-	^Future new block: self value: aValue value: anotherValue
-!
-
-futureValue: aValue value: anotherValue value: bValue
-	"Fork a synchronised evaluation of myself. Starts the
-	 evaluation in parallel immediately."
-
-	^Future new block: self value: aValue value: anotherValue value: bValue
-!
-
-futureValueWithArguments: anArray
-	"Fork a synchronised evaluation of myself. Starts the
-	 evaluation in parallel immediately."
-
-	^Future new block: self valueWithArguments: anArray
-! 
-
-parallelAnd: aBlock 
-	"Executes the receiver in parallel with aBlock. Once both   
-	 have completed, perform a logical AND operation."
-
-	| first second |
-	first := self futureValue.
-	second := aBlock futureValue.
-	^first touch & second touch!
-
-parallelEqv: aBlock 
-	"Executes the receiver in parallel with aBlock. Once both   
-	 have completed, perform a logical equivalence (exclusive-NOR)
-	 operation."
-
-	| first second |
-	first := self futureValue.
-	second := aBlock futureValue.
-	^first touch eqv: second touch!
-
-parallelOr: aBlock 
-	"Executes the receiver in parallel with aBlock. Once both   
-	 have completed, perform a logical OR operation."
-
-	| first second |
-	first := self futureValue.
-	second := aBlock futureValue.
-	^first touch | second touch!
-
-parallelPerform: aSymbol with: aBlock 
-	"Executes the receiver in parallel with aBlock. Once both  
-	 have completed, perform the operation given by aSymbol."
-
-	| first second |
-	first := self futureValue.
-	second := aBlock futureValue.
-	^first touch perform: aSymbol with: second touch!
-
-parallelXor: aBlock 
-	"Executes the receiver in parallel with aBlock. Once both   
-	 have completed, perform a logical equivalence (exclusive-NOR)
-	 operation."
-
-	| first second |
-	first := self futureValue.
-	second := aBlock futureValue.
-	^first touch xor: second touch
-! !
-
-
-"COPYRIGHT.
- The above file is a Manchester Goodie protected by copyright.
- These conditions are imposed on the whole Goodie, and on any significant
- part of it which is separately transmitted or stored:
-	* You must ensure that every copy includes this notice, and that
-	  source and author(s) of the material are acknowledged.
-	* These conditions must be imposed on anyone who receives a copy.
-	* The material shall not be used for commercial gain without the prior
-	  written consent of the author(s).
- Further information on the copyright conditions may be obtained by
- sending electronic mail:
-	To: goodies-lib@cs.man.ac.uk
-	Subject: copyright
- or by writing to The Smalltalk Goodies Library Manager, Dept of
- Computer Science, The University, Manchester M13 9PL, UK
-
- (C) Copyright 1992 University of Manchester
- For more information about the Manchester Goodies Library (from which 
- this file was distributed) send e-mail:
-	To: goodies-lib@cs.man.ac.uk
-	Subject: help 
-"!