SignalSet.st
author claus
Fri, 16 Jul 1993 11:39:45 +0200
changeset 1 a27a279701f8
child 3 24d81bf47225
permissions -rw-r--r--
Initial revision

"
 COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

IdentitySet subclass:#SignalSet
         instanceVariableNames:'special'
         classVariableNames:''
         poolDictionaries:''
         category:'Kernel-Exceptions'
!

SignalSet comment:'

COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

SignalSet allows catching of multiple signals. A SignalSet consists of
a number of signals and also implements the handle:do: method just as
signals do. However, any signal from the SignalSet will, if signalled, lead 
into the handler.
For more detail, see comment in Signal and examples in doc/coding.

%W% %E%
'!

!SignalSet class methodsFor:'instance creation'!

anySignal
    "return a new signalSet catching any signal"

    ^ self basicNew special:#any
! !

!SignalSet methodsFor:'save evaluation'!

handle:handleBlock do:aBlock
    "evaluate the argument, aBlock.
     If any of the signals in the receiver is raised during evaluation,
     evaluate the handleBlock passing it an Exception argument.
     The handler may decide how to react to the signal by sending
     a corresponding message to the exception (see there).
     If the signal is not raised, return the value of evaluating
     aBlock."

     ^ aBlock value  "the real logic is in raise/Exception"
! !

!SignalSet methodsFor:'queries'!

includes:aSignal
    "return true, if the receiver contains the argument, aSignal.
     The special any-Set includes every signal."

    (special == #any) ifTrue:[
        ^ aSignal isKindOf:Signal
    ].
    ^ super includes:aSignal
! !

!SignalSet methodsFor:'private'!

special:how
    special := how
! !