home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
aplusplus-1.01-src.lha
/
GNU
/
src
/
amiga
/
APlusPlus-1.01
/
libsource
/
SignalResponder.cxx
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-23
|
3KB
|
97 lines
/******************************************************************************
**
** C++ Class Library for the Amiga© system software.
**
** Copyright (C) 1994 by Armin Vogt ** EMail: armin@uni-paderborn.de
** All Rights Reserved.
**
** $Source: apphome:APlusPlus/RCS/libsource/SignalResponder.cxx,v $
** $Revision: 1.3 $
** $Date: 1994/04/23 21:02:29 $
** $Author: Armin_Vogt $
**
******************************************************************************/
extern "C" {
#ifdef __GNUG__
#include <inline/exec.h>
#endif
#ifdef __SASC
#include <proto/exec.h>
#endif
}
#include <APlusPlus/exec/SignalResponder.h>
volatile static char rcs_id[] = "$Id: SignalResponder.cxx,v 1.3 1994/04/23 21:02:29 Armin_Vogt Exp Armin_Vogt $";
// initialising static members
PriorityList SignalResponder::sigRespChain;
ULONG SignalResponder::waitSignalSet = 0;
void SignalResponder::initSR(BYTE signal_nr, BYTE pri)
{
_dout("SignalResponder::initSR()..\n");
waitSignalSet |= (waitSignal = 1L<<(waitSigNr=signal_nr));
_dout(BUGOUT);
sigRespChain.enqueue(this,pri);
_dout(BUGOUT);
hasAllocatedSig = FALSE;
setID(SIGRESPONDER_CLASS);
_dout("SignalResponder::initSR() done\n");
}
SignalResponder::SignalResponder( BYTE pri) : PriorityNode(0)
{
BYTE sig;
if (!(-1 == (sig = AllocSignal(-1))))
{
initSR(sig,pri);
hasAllocatedSig = TRUE;
}
else _ierror(SIGNALRESPONDER_ALLOCSIGNAL_FAILED);
}
SignalResponder::~SignalResponder()
{
if (hasAllocatedSig == TRUE) FreeSignal(waitSigNr);
remove();
}
void SignalResponder::changeSignalBit(UBYTE signal_nr)
/* Change the signal bit which the SRSP is waiting for.
*/
{
waitSignalSet |= (waitSignal = 1L<<(waitSigNr=signal_nr));
}
BOOL SignalResponder::applyNodeC(void *receivedSig)
/* On an incoming signal WaitSignal() applies this routine to every
SignalResponder created in this application. Each Responder with corresponding
wait signals set will be activated via the virtual actionCallback().
*/
{
if (waitSignal & (ULONG)receivedSig)
actionCallback();
return TRUE; // go on applying
}
void SignalResponder::WaitSignal()
/* Set the task into wait state until further signals are incoming.
*/
{
// wait for the set of signals from all responder objects
ULONG receivedSig = Wait(waitSignalSet);
// spread the received signal to all SignalResponders.
sigRespChain.apply((void*)receivedSig);
_dout("SignalResponder::WaitSignal returned.\n");
}