Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!mips!pacbell.com!tandem!zorch!amiga0!mykes From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz) Newsgroups: comp.sys.amiga.programmer Subject: Re: Window Waiting (was ) Message-ID: Date: 28 May 91 07:29:29 GMT References: <1991May24.102345.1@wombat.newcastle.edu.au> <1991May24.092943.31027@kuhub.cc.ukans.edu> <21912@cbmvax.commodore.com> <21943@cbmvax.commodore.com> Organization: Amiga makes it possible Lines: 55 In article <21943@cbmvax.commodore.com> bj@cbmvax.commodore.com (Brian Jackson) writes: >In article mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes: >>In article <21912@cbmvax.commodore.com> bj@cbmvax.commodore.com (Brian Jackson) writes: >>>The only change that I would make to this is that the ReplyMsg() call >>>should come much sooner. Let Intuition have it's message back asap. >>> >>> while((MyMsg = GetMsg(MyWindow->UserPort)) != NULL) { >>> class = MyMsg->Class ; /* make a local copy */ >>> ReplyMsg(MyMsg) ; /* reply asap */ >>> switch(class) { >>> ... >>> } >>> } >>> >>>If 'DoUpdateStuff()' is large, you hang onto Intuition's message >>>for a long time. If Intuition can't find an existing message to use >>>for the NEXT thing it wants to send to you, it will allocate memory >>>for a new one rather than use one already in existance. >>> >>Or even better is to use a structure assignment to copy the entire contents >>of the message to a private message struct before replying... > >It's only 'better' if you need the contents of the entire message. If >my program only needs, say, the Class and Code fields of an >IntuiMessage then what purpose (other than to slow things down) is >served by copying the entire 56 bytes of the IntuiMessage every time >rather than simply extracting the 6 bytes that I need ? > >Brian > > ----------------------------------------------------------------------- > | Brian Jackson Software Engineer, Commodore-Amiga Inc. GEnie: B.J. | > | bj@cbmvax.cbm.commodore.com or ...{uunet|rutgers}!cbmvax!bj | > | "We defy augury" | > ----------------------------------------------------------------------- If you are only doing simple keyboard and menupick type events, you are right, but you might also want the Qualifier and IAddress, too. if you are doing MouseButtons, you're going to want MouseX, MouseY, and possibly Seconds and Micros, too. You aren't going to know what fields you need until the "switch" statement, which is after where you should ReplyMsg(). And you should NEVER try to look at the message fields after doing the Reply... Again, I suggest a structure copy, even though you are also copying the ExecMessage, because it is a much easier/maintainable way to write event driven code. When you decide a month later that you need another field from the message structure... And the code generated by the compiler is going to be much much smaller and potentially a lot faster, especially depending on the compiler and version you use as well as the CPU (68010 and up). -- **************************************************** * I want games that look like Shadow of the Beast * * but play like Leisure Suit Larry. * ****************************************************