home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18297 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  1.8 KB

  1. Path: sparky!uunet!think.com!ames!sun-barr!rutgers!cbmvax!peter
  2. From: peter@cbmvax.commodore.com (Peter Cherna)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: RKM description of WaitPort()
  5. Message-ID: <38385@cbmvax.commodore.com>
  6. Date: 7 Jan 93 16:37:11 GMT
  7. References: <1993Jan7.122222.9718@aristo.tau.ac.il>
  8. Reply-To: peter@cbmvax.commodore.com (Peter Cherna)
  9. Organization: Commodore-Amiga, Inc.  West Chester, PA.
  10. Lines: 47
  11.  
  12. In article <1993Jan7.122222.9718@aristo.tau.ac.il> shacha1@tau.ac.il (SHEMESH SHACHAR) writes:
  13. >
  14. >Does waking up from Wait() clear the signal that caused the waking up,
  15. >or should I manually clear it with SetSignal 
  16.  
  17. >how am I to
  18. >construct a program that is to wait on sevral ports, if I want it
  19. >never to enter a busy loop in which it keeps waking up because of a
  20. >messageport with no more messages, but with a leftover signal set?
  21.  
  22. Wait() and WaitPort() clear the signal.  GetMsg() does not.  You
  23. should normally never need to call SetSignal() if you're using
  24. messages.  Try this to handle messages from two ports:
  25.  
  26.     struct MsgPort *mp1 = your first message port;
  27.     struct MsgPort *mp2 = your second message port;
  28.  
  29.     sigmask1 = 1 << mp1->mp_SigBit;
  30.     sigmask2 = 1 << mp2->mp_SigBit;
  31.  
  32.     while ( !done )
  33.     {
  34.         sigmask = Wait( sigmask1 | sigmask2 );
  35.         if ( sigmask & sigmask1 )
  36.         {
  37.             while ( msg1 = GetMsg( mp1 ) )
  38.             {
  39.                 handle messages from port 1 ...
  40.             }
  41.         }
  42.         if ( sigmask & sigmask2 )
  43.         {
  44.             while ( msg2 = GetMsg( mp2 ) )
  45.             {
  46.                 handle messages from port 2 ...
  47.             }
  48.         }
  49.     }
  50.  
  51. >Shachar Shemesh  (TheSun on IRC) shacha1@ccsg.tau.ac.il
  52.  
  53.      Peter
  54. --
  55. Peter Cherna, User Interface Development Group, Commodore-Amiga, Inc.
  56. {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
  57. My opinions do not necessarily represent the opinions of my employer.
  58. "Opinions enlarged to show detail"
  59.