Article View: comp.sys.amiga.tech
Article #11514Re: Ultimate Wait-GetMsg strategy (?)
From: Matt Dillon
Date: Sun, 19 Feb 1989 02:01
Date: Sun, 19 Feb 1989 02:01
25 lines
1227 bytes
1227 bytes
:Why not use :
:
:while (WaitPort(win->UserPort) {
: msg = GetMsg(win->UserPort);
: ......
: ReplyMsg(msg);
: if (xyz) break;
:}
:
:WaitPort() will return as long as there are _any_ messages in your port.
:Only if the port is empty will it wait for the ports SigBit.
:
:Of course this will only wait for one single port, but so does your example.
While this will work, it doesn't make much sense. WaitPort()
ALWAYS returns the first valid message on the port. If the port is empty,
WaitPort() blocks until somebody sends a message to the port and then
returns that.
Making it the argument of a while() implies that it is possible to
return a non-zero value at some point, which it isn't. Thus, the code
will confuse the hell out of anybody with less than optimal experience with
the system library.
-Matt
Technical Details
Message-ID:
<8902190201.AA20718@postgres.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!POSTGRES.BERKELEY.EDU!dillonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!POSTGRES.BERKELEY.EDU!dillon From: dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Ultimate Wait-GetMsg strategy (?) Message-ID: <8902190201.AA20718@postgres.Berkeley.EDU> Date: 19 Feb 89 02:01:13 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 25