Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!cbmvax!vu-vlsi!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: VBL or patch traps? Message-ID: <3178@carthage.cs.swarthmore.edu> Date: 17 Oct 89 15:02:24 GMT References: <189@uhura.cs.wisc.edu> Reply-To: jackiw@carthage (Nick Jackiw) Distribution: usa Organization: Visual Geometry Project, Swarthmore College, PA Lines: 32 In article <189@uhura.cs.wisc.edu> qureshi@uhura (Mohammad Qureshi) writes: > I have been considering writing an INIT that would, after a set time, present > a dialog to the user. This would be a sort of alarm which the user would > be able to set (using a cdev interface). My question is, should I implement > this alarm as a VBL task, checking each time if one of the alarm times has > been reached, or should I patch WaitNextEvent/GetNextEvent and/or appropriate > traps to check whether or not the alarm should go off? > > Any assistance will be greatly appreciated. I'd definitely go with the trap patch, not the VBL. That way, while you may take up more or less processor cycles than a VBL (depending on the frequency of calls to WNE), you're guaranteed to be doing it at a time when the foreground application is "looking for something else to do", as opposed to doing it during the middle of somebody else's processor- intensive computations. Furthermore, you've got a *lot* more flexibility in memory access and toolbox use in an event-loop trap than you do running at interrupt level. Lastly, you can take as much time as you like if it's not in a VBL---they didn't name it "WAITnextEvent" for nothing :-)! -Nick -- _ _|\____ Nick Jackiw | Visual Geometry Project | Math Department / /_/ O> \ ------------+-------------------------+ Swarthmore College | O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081 \_Guernica_/ ------------+-------------------------+ USA