*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Thu, 19 Nov 2009 16:38:25 +0100
changeset 2341 36e455705ee6
parent 2340 2dc6e31f0142
child 2342 38861b2f8539
*** empty log message ***
Future.st
Lazy.st
--- a/Future.st	Tue Nov 17 11:36:11 2009 +0100
+++ b/Future.st	Thu Nov 19 16:38:25 2009 +0100
@@ -15,13 +15,13 @@
  Computer Science, The University, Manchester M13 9PL, UK
 
  (C) Copyright 1992 University of Manchester
- For more information about the Manchester Goodies Library (from which 
+ 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 
+	Subject: help
 "
 
-"{ Package: 'stx:goodies' }"
+"{ Package: 'stx:libbasic2' }"
 
 ProtoObject subclass:#Future
 	instanceVariableNames:'result semaphore'
@@ -50,24 +50,24 @@
  Computer Science, The University, Manchester M13 9PL, UK
 
  (C) Copyright 1992 University of Manchester
- For more information about the Manchester Goodies Library (from which 
+ 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 
+	Subject: help
 "
 !
 
 documentation
 "
-    I represent an execution in progress.  
+    I represent an execution in progress.
     I will immediately start execution in a separate process.
     Any messages sent to me are delayed until execution has completed.'
 
-    [author:]        
-        tph@cs.man.ac.uk
+    [author:]
+	tph@cs.man.ac.uk
 
     [see also:]
-        Block Lazy LazyValue
+	Block Lazy LazyValue
 "
 !
 
@@ -75,13 +75,13 @@
 "
   Starts evaluating the factorial immediately, but waits until
   the result is available before printing the answer
-                                                                    [exBegin]
+								    [exBegin]
     | fac |
 
     fac := [5000 factorial] futureValue.
     Transcript showCR: 'evaluating factorial...'.
     Transcript showCR: fac printString
-                                                                    [exEnd]
+								    [exEnd]
 
 
   An example illustrating the use of multiple futures and
@@ -89,7 +89,7 @@
 
   Starts evaluating both factorials immediately, but waits until
   both blocks have finished before continuing.
-                                                                    [exBegin]
+								    [exBegin]
     | fac1 fac2 |
 
     fac1 := [Transcript showCR: 'Starting fac1.. '. 1000 factorial] futureValue.
@@ -97,16 +97,16 @@
     fac2 isString.
     fac1 isString.
     Transcript showCR: 'both completed.'.
-                                                                    [exEnd]
+								    [exEnd]
 
   Example showing how arguments may be passed to futures.
-                                                                    [exBegin]
+								    [exBegin]
     | temp |
 
     temp := [:x :y | 10 * x * y] futureValue: 3 value: 4.
     Transcript  showCR: temp printString.
 
-                                                                    [exEnd]
+								    [exEnd]
 
   Claus:
     The above examples do not really show the power of Futures;
@@ -116,44 +116,44 @@
 
     Here, the input is read before - the readTime and view creation
     times sum up:
-                                                                    [exBegin]
-        |p text v|
+								    [exBegin]
+	|p text v|
 
-        p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
-        text := p contents.
-        p close.
-        v := TextView new openAndWait.
-        v contents:text
-                                                                    [exEnd]
+	p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
+	text := p contents.
+	p close.
+	v := TextView new openAndWait.
+	v contents:text
+								    [exEnd]
 
     The same here:
-                                                                    [exBegin]
-        |p text v|
+								    [exBegin]
+	|p text v|
 
-        v := TextView new openAndWait.
-        p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
-        text := p contents.
-        p close.
-        v contents:text
-                                                                    [exEnd]
+	v := TextView new openAndWait.
+	p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
+	text := p contents.
+	p close.
+	v contents:text
+								    [exEnd]
 
 
     Here, the view creation and reading are done in parallel:
     (if the user is slow when opening the view, the contents may
      be already available)
-                                                                    [exBegin]
-        |p text v|
+								    [exBegin]
+	|p text v|
 
-        text := [   |p t|
+	text := [   |p t|
 
-                    p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
-                    t := p contents.
-                    p close.
-                    t
-                ] futureValue.
-        v := TextView new openAndWait.
-        v contents:text
-                                                                    [exEnd]
+		    p := PipeStream readingFrom:'ls -l /bin /usr/bin /usr/lib'.
+		    t := p contents.
+		    p close.
+		    t
+		] futureValue.
+	v := TextView new openAndWait.
+	v contents:text
+								    [exEnd]
 "
 ! !
 
@@ -175,9 +175,9 @@
 
     semaphore := Semaphore new name:'Future'.
     [
-        result := [
-            aBlock value:aValue
-        ] ensure:[semaphore signal]
+	result := [
+	    aBlock value:aValue
+	] ensure:[semaphore signal]
     ] fork
 !
 
@@ -188,9 +188,9 @@
 
     semaphore := Semaphore new name:'Future'.
     [
-        result := [
-            aBlock value: value1 value: value2
-        ] ensure:[semaphore signal]
+	result := [
+	    aBlock value: value1 value: value2
+	] ensure:[semaphore signal]
     ] fork
 !
 
@@ -201,9 +201,9 @@
 
     semaphore := Semaphore new name:'Future'.
     [
-        result := [
-            aBlock value: value1 value: value2 value: value3
-        ] ensure:[semaphore signal]
+	result := [
+	    aBlock value: value1 value: value2 value: value3
+	] ensure:[semaphore signal]
     ] fork
 !
 
@@ -214,19 +214,19 @@
 
     semaphore := Semaphore new name:'Future'.
     [
-        result := [
-            aBlock valueWithArguments: anArray
-        ] ensure:[semaphore signal]
+	result := [
+	    aBlock valueWithArguments: anArray
+	] ensure:[semaphore signal]
     ] fork
 ! !
 
 !Future methodsFor:'synchronising'!
 
-doesNotUnderstand:aMessage 
+doesNotUnderstand:aMessage
     "Any message to a Future will end up here."
-    
+
     semaphore waitUncounted. "Wait for evaluation to complete"
-                             "(if not already completed)" 
+			     "(if not already completed)"
     ^ result perform:aMessage selector withArguments:aMessage arguments
 ! !
 
@@ -243,5 +243,5 @@
 !Future class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.10 2005-01-26 13:55:27 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Future.st,v 1.11 2009-11-19 15:38:25 cg Exp $'
 ! !
--- a/Lazy.st	Tue Nov 17 11:36:11 2009 +0100
+++ b/Lazy.st	Thu Nov 19 16:38:25 2009 +0100
@@ -15,13 +15,13 @@
  Computer Science, The University, Manchester M13 9PL, UK
 
  (C) Copyright 1992 University of Manchester
- For more information about the Manchester Goodies Library (from which 
+ 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 
+	Subject: help
 "
 
-"{ Package: 'stx:goodies' }"
+"{ Package: 'stx:libbasic2' }"
 
 ProtoObject subclass:#Lazy
 	instanceVariableNames:'result startSemaphore endSemaphore'
@@ -50,24 +50,24 @@
  Computer Science, The University, Manchester M13 9PL, UK
 
  (C) Copyright 1992 University of Manchester
- For more information about the Manchester Goodies Library (from which 
+ 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 
+	Subject: help
 "
 !
 
 documentation
 "
-    I represent an execution which may not be required.  
-    I will not start execution until at least one message has been received.  
+    I represent an execution which may not be required.
+    I will not start execution until at least one message has been received.
     The messages sent to me are delayed until execution has completed.
 
-    [author:]        
-        tph@cs.man.ac.uk
+    [author:]
+	tph@cs.man.ac.uk
 
     [see also:]
-        Block LazyValue Future
+	Block LazyValue Future
 "
 !
 
@@ -75,33 +75,33 @@
 "
   Evaluates the factorial, starting only when the
   result is actually required (when printString is sent).
-                                                [exBegin]       
+						[exBegin]
     | fac |
     fac := [100 factorial] lazyValue.
     Transcript showCR: 'Doing nothing. '.
     (Delay forSeconds: 2) wait.
     Transcript showCR: fac printString.
-                                                [exEnd]       
+						[exEnd]
 
 
   Starts evaluating both factorials only when required (by the touch),
   and waits until both blocks have finished before continuing.
-                                                [exBegin]       
+						[exBegin]
     | fac1 fac2 |
     fac1 := [Transcript showCR: 'Starting fac1.. '. 100 factorial] lazyValue.
     fac2 := [Transcript showCR: 'Starting fac2.. '. 120 factorial] lazyValue.
     fac2 touch.
     fac1 touch.
     Transcript showCR: 'both completed.'.
-                                                [exEnd]       
+						[exEnd]
 
 
   Demonstrates how to pass arguments to a lazy evaluation block.
-                                                [exBegin]       
+						[exBegin]
     | temp |
     temp := [:x :y :z | x * y * z] lazyValueWithArguments: #(2 3 4).
     Transcript  showCR: temp printString.
-                                                [exEnd]       
+						[exEnd]
 "
 ! !
 
@@ -175,22 +175,22 @@
 !Lazy methodsFor:'synchronising'!
 
 doesNotUnderstand: aMessage
-        "Any message to a Lazy will end up here."
+	"Any message to a Lazy will end up here."
 
-        startSemaphore signal.          "Start the evaluation."
-        endSemaphore waitUncounted.     "Wait until evaluation completed."
+	startSemaphore signal.          "Start the evaluation."
+	endSemaphore waitUncounted.     "Wait until evaluation completed."
 
-        ^result perform: aMessage selector withArguments: aMessage arguments
+	^result perform: aMessage selector withArguments: aMessage arguments
 ! !
 
 !Lazy methodsFor:'testing'!
 
 isLazyValue
-    ^ endSemaphore wouldBlock 
+    ^ endSemaphore wouldBlock
 ! !
 
 !Lazy class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Lazy.st,v 1.7 2005-01-26 13:54:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Lazy.st,v 1.8 2009-11-19 15:38:25 cg Exp $'
 ! !