home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!ames!sun-barr!rutgers!cbmvax!peter
- From: peter@cbmvax.commodore.com (Peter Cherna)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: RKM description of WaitPort()
- Message-ID: <38385@cbmvax.commodore.com>
- Date: 7 Jan 93 16:37:11 GMT
- References: <1993Jan7.122222.9718@aristo.tau.ac.il>
- Reply-To: peter@cbmvax.commodore.com (Peter Cherna)
- Organization: Commodore-Amiga, Inc. West Chester, PA.
- Lines: 47
-
- In article <1993Jan7.122222.9718@aristo.tau.ac.il> shacha1@tau.ac.il (SHEMESH SHACHAR) writes:
- >
- >Does waking up from Wait() clear the signal that caused the waking up,
- >or should I manually clear it with SetSignal
-
- >how am I to
- >construct a program that is to wait on sevral ports, if I want it
- >never to enter a busy loop in which it keeps waking up because of a
- >messageport with no more messages, but with a leftover signal set?
-
- Wait() and WaitPort() clear the signal. GetMsg() does not. You
- should normally never need to call SetSignal() if you're using
- messages. Try this to handle messages from two ports:
-
- struct MsgPort *mp1 = your first message port;
- struct MsgPort *mp2 = your second message port;
-
- sigmask1 = 1 << mp1->mp_SigBit;
- sigmask2 = 1 << mp2->mp_SigBit;
-
- while ( !done )
- {
- sigmask = Wait( sigmask1 | sigmask2 );
- if ( sigmask & sigmask1 )
- {
- while ( msg1 = GetMsg( mp1 ) )
- {
- handle messages from port 1 ...
- }
- }
- if ( sigmask & sigmask2 )
- {
- while ( msg2 = GetMsg( mp2 ) )
- {
- handle messages from port 2 ...
- }
- }
- }
-
- >Shachar Shemesh (TheSun on IRC) shacha1@ccsg.tau.ac.il
-
- Peter
- --
- Peter Cherna, User Interface Development Group, Commodore-Amiga, Inc.
- {uunet|rutgers}!cbmvax!peter peter@cbmvax.commodore.com
- My opinions do not necessarily represent the opinions of my employer.
- "Opinions enlarged to show detail"
-