class: Block
authorStefan Vogel <sv@exept.de>
Fri, 23 Jun 2017 11:47:07 +0200
changeset 4448 f9bbcb40b337
parent 4447 cbe19db976ec
child 4449 5d3b0d56cfd3
class: Block move libbasic2 extension methods to libbasic2
extensions.st
--- a/extensions.st	Thu Jun 22 17:09:09 2017 +0200
+++ b/extensions.st	Fri Jun 23 11:47:07 2017 +0200
@@ -92,6 +92,176 @@
     "Created: / 13-06-2017 / 08:54:27 / cg"
 ! !
 
+!Block methodsFor:'Compatibility-Dolphin'!
+
+deferredValue
+    "Dolphin compatibility method - do not use in new code.
+     Dolphin's alias for futureValue"
+
+    ^ Future new block:self
+
+    "Modified: / 04-10-2011 / 14:56:27 / cg"
+! !
+
+!Block methodsFor:'Compatibility-Dolphin'!
+
+deferredValueAt:priority
+    "Dolphin compatibility method - do not use in new code.
+     Dolphin's alias for futureValue"
+
+    ^ Future new
+	priority:priority block:self
+
+    "Created: / 04-10-2011 / 14:55:56 / cg"
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+futureValue
+    "Fork a synchronised evaluation of myself.
+     Starts the evaluation in parallel now, but synchronizes
+     any access to wait until the result is computed."
+
+    ^ Future new block:self
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+futureValue:aValue
+    "Fork a synchronised evaluation of myself.
+     Starts the evaluation in parallel now, but synchronizes
+     any access to wait until the result is computed."
+
+    ^ Future new block:self value:aValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+futureValue:aValue value:anotherValue
+    "Fork a synchronised evaluation of myself.
+     Starts the evaluation in parallel now, but synchronizes
+     any access to wait until the result is computed."
+
+    ^ Future new
+	block:self
+	value:aValue
+	value:anotherValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+futureValue:aValue value:anotherValue value:bValue
+    "Fork a synchronised evaluation of myself.
+     Starts the evaluation in parallel now, but synchronizes
+     any access to wait until the result is computed."
+
+    ^ Future new
+	block:self
+	value:aValue
+	value:anotherValue
+	value:bValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+futureValueWithArguments:anArray
+    "Fork a synchronised evaluation of myself.
+     Starts the evaluation in parallel now, but synchronizes
+     any access to wait until the result is computed."
+
+    ^ Future new
+	block:self
+	valueWithArguments:anArray
+
+    "Modified (format): / 04-10-2011 / 14:55:40 / cg"
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+lazyValue
+    "Fork a synchronised evaluation of myself. Only starts
+     the evaluation when the result is requested."
+
+    ^ Lazy new block:self
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+lazyValue:aValue
+    "Fork a synchronised evaluation of myself. Only starts
+     the evaluation when the result is requested."
+
+    ^ Lazy new block:self value:aValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+lazyValue:aValue value:anotherValue
+    "Fork a synchronised evaluation of myself. Only starts
+     the evaluation when the result is requested."
+
+    ^ Lazy new
+	block:self
+	value:aValue
+	value:anotherValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+lazyValue:aValue value:anotherValue value:bValue
+    "Fork a synchronised evaluation of myself. Only starts
+     the evaluation when the result is requested."
+
+    ^ Lazy new
+	block:self
+	value:aValue
+	value:anotherValue
+	value:bValue
+! !
+
+!Block methodsFor:'parallel evaluation'!
+
+lazyValueWithArguments:anArray
+    "Fork a synchronised evaluation of myself. Only starts
+     the evaluation when the result is requested."
+
+    ^ Lazy new block:self valueWithArguments:anArray
+! !
+
+!Block methodsFor:'process creation'!
+
+promise
+    "create a promise on the receiver. The promise will evaluate the
+     receiver and promise to return the value with the #value message.
+     The evaluation will be performed as a separate process.
+     Asking the promise for its value will either block the asking process
+     (if the evaluation has not yet been finished) or return the value
+     immediately."
+
+    ^ Promise value:self
+
+    "
+     |p|
+
+     p := [1000 factorial] promise.
+     'do something else ...'.
+     p value
+    "
+! !
+
+!Block methodsFor:'process creation'!
+
+promiseAt:prio
+    "create a promise on the receiver. The promise will evaluate the
+     receiver and promise to return the value with the #value message.
+     The evaluation will be performed as a separate process running at prio.
+     Asking the promise for its value will either block the asking process
+     (if the evaluation has not yet been finished) or return the value
+     immediately."
+
+    ^ Promise value:self priority:prio
+! !
+
 !CharacterArray methodsFor:'matching - phonetic'!
 
 asKoelnerPhoneticCode