Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!news.cs.indiana.edu!rutgers!rochester!kodak!uupsi!sunic!news.funet.fi!cc.tut.fi!cc.tut.fi!n67786 From: n67786@cc.tut.fi (Tero Nieminen) Newsgroups: comp.sys.mac.programmer Subject: Re: Questions about multitasking on the mac Message-ID: Date: 12 May 91 01:42:27 GMT References: <1991May11.191114.27564@potomac.ads.com> Sender: n67786@cc.tut.fi (Tero Nieminen) Organization: Tampere Univ. of Technology, Finland. Lines: 38 In-Reply-To: jtn@potomac.ads.com's message of 11 May 91 19:11:14 GMT In article <1991May11.191114.27564@potomac.ads.com> jtn@potomac.ads.com (John T. Nelson) writes: No I don't want to start yet ANOTHER flamewar on what type of multitasking is the One And True Multitasking. Rather I have a legitimate question concerning how one passes control onto other apps running cooperatively on the Mac. Let's say I have a large and complex compiler (which I do) and let's say that it consists of lots of hairy recursive-decent style code. It's difficult to modularize this particular code so I can't call lots of modules from the event loop. Basically we go into the compiler and come back out when done. I had this same problem with a cde that had a lengthy sort procedure. And for the speed I used quick sort which is recursive. In effect one has to include one WaitNextEvent call to every recursion that the code takes in this case to both two halves of the quick sort recursion. In order to prevent the sort calling WaitNextEvent in every recursion, which would be way too much and allso slow down the sort unnecessarily, I capsulated the sort into a module and made a module global that keeps a count of the times the sort has been recursing since last WaitNextEvent, and only call it if enough sorting has taken place. In practice every recursion increments the variable and when a preset value is reached WNE is called and the variable reset. Actually I did call a bit more than just WNE. If I recall correctly the reason why a simple WNE was not enough was that the window of my program would not redraw itself after switching between background and foreground or something of that nature. Probably the best way to to do something like that is to pass a procedure as a parameter to be called often enough during such lengthy operations. In any case it surely doesn't make modularising programs very simple neither too clean.. -- Tero Nieminen Tampere University of Technology n67786@cc.tut.fi Tampere, Finland, Europe