#REFACTORING by stefan
class: Block
changed:
#valueAt:
#valueWithWatchDog:afterMilliseconds:
move libbasic2 extension methods to libbasic2
--- a/Block.st Fri Jun 23 10:59:10 2017 +0200
+++ b/Block.st Fri Jun 23 11:48:13 2017 +0200
@@ -504,26 +504,6 @@
"
! !
-!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"
-!
-
-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:'Compatibility-Squeak'!
@@ -1692,27 +1672,27 @@
i.e. change the priority for the execution of the receiver.
Bad name: should be called evaluateWithPriority: or similar"
- |oldPrio retVal activeProcess|
+ |oldPrio activeProcess|
activeProcess := Processor activeProcess.
oldPrio := Processor activePriority.
- [
- activeProcess priority:priority.
- retVal := self value.
+ ^ [
+ activeProcess priority:priority.
+ self value.
] ensure:[
- activeProcess priority:oldPrio
+ activeProcess priority:oldPrio
].
- ^ retVal
"
[
- 1000 timesRepeat:[
- 1000 factorial
- ]
+ 1000 timesRepeat:[
+ 1000 factorial
+ ]
] valueAt:3
"
- "Created: / 29.7.1998 / 19:19:48 / cg"
+ "Created: / 29-07-1998 / 19:19:48 / cg"
+ "Modified: / 23-06-2017 / 11:13:30 / stefan"
!
valueWithArguments:argArrayIn
@@ -2517,32 +2497,35 @@
exceptionBlock's value is returned. The receiver's code must be prepared
for premature returning (by adding ensure blocks, as required)"
- |showStopper me retVal done inError|
-
- done := inError := false.
- me := Processor activeProcess.
-
- showStopper :=
- [
- done ifFalse:[
- me interruptWith:[
- (Processor activeProcess state ~~ #debug) ifTrue:[
- done ifFalse:[ TimeoutNotification raiseRequest ]
- ]
- ]
- ]
- ].
+ |retVal inError|
+
+ inError := false.
TimeoutNotification handle:[:ex |
inError ifTrue:[
ex proceed
].
- retVal := exceptionBlock value.
+ ^ exceptionBlock value.
] do:[
NoHandlerError handle:[:ex |
inError := true.
ex reject.
] do:[
+ |showStopper me done|
+
+ done := false.
+ me := Processor activeProcess.
+ showStopper :=
+ [
+ done ifFalse:[
+ me interruptWith:[
+ (me state ~~ #debug) ifTrue:[
+ done ifFalse:[ TimeoutNotification raiseRequest ]
+ ]
+ ]
+ ]
+ ].
+
[
Processor
addTimedBlock:showStopper
@@ -2567,6 +2550,7 @@
"Modified: / 21-05-2010 / 12:19:57 / sr"
"Modified: / 19-03-2017 / 18:13:07 / cg"
+ "Modified (format): / 23-06-2017 / 11:24:03 / stefan"
! !
!Block methodsFor:'exception handling private'!
@@ -2988,100 +2972,6 @@
"
! !
-!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
-!
-
-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
-!
-
-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
-!
-
-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
-!
-
-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"
-!
-
-lazyValue
- "Fork a synchronised evaluation of myself. Only starts
- the evaluation when the result is requested."
-
- ^ Lazy new block:self
-!
-
-lazyValue:aValue
- "Fork a synchronised evaluation of myself. Only starts
- the evaluation when the result is requested."
-
- ^ Lazy new block:self value:aValue
-!
-
-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
-!
-
-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
-!
-
-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:'printing & storing'!
@@ -3296,36 +3186,6 @@
passing the elements in argArray as arguments to the receiver block."
^ [self valueWithArguments:argArray] newProcess
-!
-
-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
- "
-!
-
-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
! !
!Block methodsFor:'testing'!