SignalSet.st
author claus
Sun, 09 Jan 1994 22:25:58 +0100
changeset 41 a14247b04d03
parent 3 24d81bf47225
child 44 b262907c93ea
permissions -rw-r--r--
*** empty log message ***

"
 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.

$Header: /cvs/stx/stx/libbasic/SignalSet.st,v 1.4 1994-01-09 21:24:33 claus Exp $
'!

!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
    "set the special inst"

    special := how
! !