SignalSet.st
branchjv
changeset 18120 e3a375d5f6a8
parent 18045 c0c600e0d3b3
parent 16562 de9b98f4a494
child 19478 1f5aa87f6170
--- a/SignalSet.st	Tue Feb 04 21:09:59 2014 +0100
+++ b/SignalSet.st	Wed Apr 01 10:20:10 2015 +0100
@@ -52,7 +52,7 @@
 "
     SignalSet allows catching of multiple signals. A SignalSet consists of
     a number of signals and also implements the #handle:do: and #catch: methods
-    just as signals do. 
+    just as signals do.
     However, any signal from the SignalSet will, if signalled, lead into the handler.
 
     There is also a special signalSet, which can be used to catch any
@@ -69,12 +69,12 @@
 
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 
     [see also:]
-        Exception 
-        Signal QuerySignal
-        Object
+	Exception
+	Signal QuerySignal
+	Object
 "
 ! !
 
@@ -83,9 +83,9 @@
 anySignal
     "return a special signalSet for catching any signal.
      Questionable:
-        you should use 'Object>>errorSignal' for that purpose;
-        however, the anySignal-set also catches nonChilds of the ErrorSignal
-        (i.e. highly private, strange signals)."
+	you should use 'Object>>errorSignal' for that purpose;
+	however, the anySignal-set also catches nonChilds of the ErrorSignal
+	(i.e. highly private, strange signals)."
 
     ^ SetOfAnySignal new
 
@@ -106,7 +106,7 @@
      and raises a MessageNotUnderstood error."
 
     anExceptionHandler isExceptionHandler ifFalse:[
-        SignalError raiseWith:anExceptionHandler errorString:' - trying to add a non-exceptionHandler to a SignalSet'.
+	SignalError raiseWith:anExceptionHandler errorString:' - trying to add a non-exceptionHandler to a SignalSet'.
     ].
     ^ super add:anExceptionHandler.
 ! !
@@ -118,9 +118,9 @@
      (i.e. if any of the receivers elements is aSignal or a parent of it).
      False otherwise."
 
-    self do:[:eachExceptionHandler | 
-        (eachExceptionHandler==anExceptionHandler 
-         or:[eachExceptionHandler accepts:anExceptionHandler]) ifTrue:[^ true].
+    self do:[:eachExceptionHandler |
+	(eachExceptionHandler==anExceptionHandler
+	 or:[eachExceptionHandler accepts:anExceptionHandler]) ifTrue:[^ true].
     ].
     ^ false
 !
@@ -141,14 +141,14 @@
     selector := theContext selector.
     (selector ~~ #'handle:from:do:'
      or:[(theContext argAt:2) == originator]) ifTrue:[
-        (self == signal or:[self accepts:signal]) ifTrue:[
-            arg := theContext argAt:1.
-            selector == #answer:do: ifTrue:[
-                ^ [:ex| ex proceedWith:arg].
-            ] ifFalse:[
-                ^ arg ? [nil].
-            ].
-        ]
+	(self == signal or:[self accepts:signal]) ifTrue:[
+	    arg := theContext argAt:1.
+	    selector == #answer:do: ifTrue:[
+		^ [:ex| ex proceedWith:arg].
+	    ] ifFalse:[
+		^ arg ? [nil].
+	    ].
+	]
     ].
     ^ nil
 
@@ -159,14 +159,14 @@
     "set the handlerProtectedBlock in context"
 
     context selector == #handle:do: ifTrue:[
-        context argAt:2 put:doBlock.
+	context argAt:2 put:doBlock.
     ] ifFalse:[context selector == #handle:from:do: ifTrue:[
-        context argAt:3 put:doBlock.
+	context argAt:3 put:doBlock.
     ]].
 
     "
       SignalSet anySignal
-          handle:[:ex| ex restartDo:[55]] do:[1 // 0]
+	  handle:[:ex| ex restartDo:[55]] do:[1 // 0]
     "
 
 
@@ -177,8 +177,8 @@
     "return true, if the receiver handles the argument, anException.
      (i.e. if any of the receivers elements handles anException)."
 
-    self do:[:eachExceptionHandler| 
-        (eachExceptionHandler handles:anException) ifTrue:[^ true]
+    self do:[:eachExceptionHandler|
+	(eachExceptionHandler handles:anException) ifTrue:[^ true]
     ].
     ^ false
 !
@@ -206,9 +206,9 @@
 
 catch:aBlock
     "evaluate the argument, aBlock.
-     If any of the signals in the receiver is raised during evaluation, 
-     abort the evaluation and return true; otherwise return false. 
-     With the special anySignal, evaluation can be performed totally save 
+     If any of the signals in the receiver is raised during evaluation,
+     abort the evaluation and return true; otherwise return false.
+     With the special anySignal, evaluation can be performed totally save
      from signals - but who (beside radical c++ fans) would do that ?"
 
     |raiseOccurred|
@@ -219,7 +219,7 @@
 
      "
       SignalSet anySignal catch:[
-         (#(1 2 3 4) at:5) / 0.0
+	 (#(1 2 3 4) at:5) / 0.0
       ]
      "
 !
@@ -232,35 +232,35 @@
      If the signal is raised multiple times, only the first raises parameter is remembered,
      and only a single raise is performed after the blocks evaluation.
 
-     Deferring makes sense for some signals, such as UserInterrupt or AbortSignal, 
-     which must occasionally be delayed temprarily until a save place is reached 
+     Deferring makes sense for some signals, such as UserInterrupt or AbortSignal,
+     which must occasionally be delayed temprarily until a save place is reached
      (especially when packages are sent across a communication channel, and you dont want
       partial packages to be generated by user interruptions)."
 
-    |coughtException result|
+    |caughtException result|
 
     self handle:[:ex |
-        coughtException isNil ifTrue:[
-            coughtException := ex.
-        ].
-        ex proceedWith:nil
+	caughtException isNil ifTrue:[
+	    caughtException := ex.
+	].
+	ex proceedWith:nil
     ] do:[
-        result := aBlock value.
+	result := aBlock value.
     ].
-    coughtException notNil ifTrue:[
-        coughtException suspendedContext:thisContext.
+    caughtException notNil ifTrue:[
+	caughtException suspendedContext:thisContext.
 
-        "/ a signal was raised during the execution of aBlock above. 
-        "/ Raise it now (delayed).
-        coughtException raiseSignal
+	"/ a signal was raised during the execution of aBlock above.
+	"/ Raise it now (delayed).
+	caughtException raiseSignal
     ].
     ^ result
 
     "
      (UserInterrupt , AbortOperationRequest) deferAfter:[
-         Transcript showCR:'1 - now raising, but will be deferred.'.
-         UserInterrupt raiseRequestWith:'hello'.
-         Transcript showCR:'2 - after the raise, deferred exception will be handled soon.'.
+	 Transcript showCR:'1 - now raising, but will be deferred.'.
+	 UserInterrupt raiseRequestWith:'hello'.
+	 Transcript showCR:'2 - after the raise, deferred exception will be handled soon.'.
      ].
      Transcript showCR:'3 - here after the protected block.'.
     "
@@ -283,18 +283,18 @@
 
     "
      SignalSet anySignal handle:[:ex |
-        ex errorString print. ' occured in: ' print. ex suspendedContext printNL.
-        ex return
+	ex errorString print. ' occured in: ' print. ex suspendedContext printNL.
+	ex return
      ] do:[
-        (#(1 2 3 4) at:5) / 0.0
+	(#(1 2 3 4) at:5) / 0.0
      ]
 
      SignalSet anySignal handle:[:ex |
-        ex errorString print. ' occured in: ' print. ex suspendedContext printNL.
-        self bar.
-        ex return
+	ex errorString print. ' occured in: ' print. ex suspendedContext printNL.
+	self bar.
+	ex return
      ] do:[
-        (#(1 2 3 4) at:5) / 0.0
+	(#(1 2 3 4) at:5) / 0.0
      ]
     "
 
@@ -331,7 +331,7 @@
 
      "
       SignalSet anySignal ignoreIn:[
-         123 size open   
+	 123 size open
       ]
      "
 
@@ -361,7 +361,7 @@
     "returns a singleton"
 
     theOneAndOnlyInstance isNil ifTrue:[
-        theOneAndOnlyInstance := self basicNew initialize.
+	theOneAndOnlyInstance := self basicNew initialize.
     ].
     ^ theOneAndOnlyInstance.
 ! !
@@ -402,10 +402,9 @@
 !SignalSet class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SignalSet.st,v 1.46 2013-04-04 09:39:46 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SignalSet.st,v 1.47 2014-06-10 10:20:23 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/SignalSet.st,v 1.46 2013-04-04 09:39:46 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SignalSet.st,v 1.47 2014-06-10 10:20:23 cg Exp $'
 ! !
-