← develop-13 9313 March 1993

develop-13 9313 March 1993

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

develop The Apple Technical Journal ASYNCHRONOUS ROUTINES ON THE MACINTOSH INSIDE QUICKTIME AND COMPONENT-BASED MANAGERS MACINTOSH DEBUGGING: THE BELLY OF THE BEAST REVISITED ADVENTURES IN COLOR PRINTING DEVICELOOP MEETS THE INTERFACE DESIGNER LOOKING AHEAD TO PRINTING IN QUICKDRAW GX THE PALETTE MANAGER WAY KON & BAL'S PUZZLE PAGE MACINTOSH Q & A NEW QUICKTIME COLUMN: TOP 10 QUICKTIME TIPS Issue 13 March 1993

A magazine cover with a bold 'develop' masthead and a brown textured background featuring a central blue-green photographic panel with birds, overlaid by glowing yellow circuit-like lines and red and green spherical nodes, with a column of cover-story titles on the right and an Apple logo at the bottom.

Reading notes: Small masthead subtitle and footer text are slightly faint but legible; reading order of right-column headlines is top to bottom.

Printed product names
develop
Printed dates
March 1993
Languages
English
PDF page 1

develop The Apple Technical Journal ASYNCHRONOUS ROUTINES ON THE MACINTOSH INSIDE QUICKTIME AND COMPONENT-BASED MANAGERS MACINTOSH DEBUGGING: THE BELLY OF THE BEAST REVISITED ADVENTURES IN COLOR PRINTING DEVICELOOP MEETS THE INTERFACE DESIGNER LOOKING AHEAD TO PRINTING IN QUICKDRAW GX THE PALETTE MANAGER WAY KON & BAL'S PUZZLE PAGE MACINTOSH Q & A NEW QUICKTIME COLUMN: TOP 10 QUICKTIME TIPS Issue 13 March 1993

A magazine cover with a textured bronze-brown background, a central vertical panel showing a blue-green cloudy image with faint wing-like shapes, glowing yellow circuit-like lines connecting red and green spheres, and a column of bold black cover lines on a white right side with an Apple logo at lower right.

Reading notes: Lowercase masthead 'develop' with letter spacing is stylized and read as a title rather than a headline; headline field uses it as the primary masthead. Small tagline 'The Apple Technical Journal' is widely letter-spaced and may be imperfectly rendered. Faint smudge or stain near the top right of the white column does not obscure text.

Printed product names
develop · The Apple Technical Journal
Printed dates
March 1993
Languages
English
PDF page 2

E D I T O R I A L S T A F F Editor-in-Cheek Caroline Rose Technical Buckstopper Dave Johnson Our Boss Greg Joswiak His Boss David Krathwohl Review Board Pete (“Luke”) Alexander, N eil Day, C. K. Haun, Jim Reekes, Bryan K. (“Beaker”) Ressler, Larry Rosenstein, Andy Shebanow, Gregg W illiams Managing Editor M onica M effert Assistant Managing Editor Cynthia Jasper Contributing Editors Lorraine Anderson, Geta Carlson, Toni Haskell, Judy Helfand, Rilla Reynolds Indexer Ira Kleinberg A R T & P R O D U C T I O N Production Manager Hartley Lesser Art Director Diane W ilcox Technical Illustration Dave Olmos, John Ryan Formatting Forbes M ill Press Printing Wolfer Printing Company, Inc. Film Preparation Aptos Post, Inc. Production PrePress Assembly Photography Sharon Beals, Lisa Jongewaard, Tom Sandborn Online Production Cassi Carpenter develop, T he Apple Technical Journal, is a quarterly publication of Apple Computer’s Developer Support Information group. Mark Jenkins of Rucker Huggins created this beautiful image depicting asynchronous routines by synchronizing four graphics applications: Adobe Photoshop, Adobe Illustrator, Ray Dream Designer, and Fractal Design Painter. The Developer CD Series disc for March 1993 or later contains this issue and all back issues of develop along with the code that the articles describe. The develop issues and code are also available on AppleLink and via anonymous ftp on ftp.apple.com.

Reading notes: No separate headline is visible in the supplied copy; the section label 'E D I T O R I A L S T A F F' is spaced-out and may be a heading, so headline is set to null. Possible OCR spacing or character artifacts in names and titles, such as 'Editor-in-Cheek', 'N eil Day', 'M onica M effert', 'W ilcox', 'Forbes M ill Press', and 'T he Apple Technical Journal'. The phrase 'develop, T he Apple Technical Journal,' may have a split or misordered title in the source text. Product names listed are software and publication names mentioned in the colophon rather than explicitly advertised products; no advertised prices appear. Layout and reading order of the two-column staff listing cannot be verified from the supplied text alone.

Printed product names
develop · Developer CD Series · Adobe Photoshop · Adobe Illustrator · Ray Dream Designer · Fractal Design Painter · AppleLink
Printed dates
March 1993
Languages
English
PDF page 3

CONTENTS March 1993 1 © 1993 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, APDA, Apple IIGS, AppleLink, AppleShare, AppleTalk, ImageWriter, LaserWriter, MacApp, Macintosh, MPW, MultiFinder, ProDOS, SANE, and StyleWriter are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. AppleGlot, ColorSync, develop, DocViewer, the dogcow logo, Finder, Moof, MoviePlayer, PhotoGrade, PowerBook, QuickDraw, QuickTime, Sound Manager, System 7, and TrueType are trademarks of Apple Computer, Inc. PostScript and Adobe are trademarks of Adobe Systems Incorporated, which may be registered in certain jurisdictions. HyperCard and MacWrite are registered trademarks of Claris Coporation. NuBus is a trademark of Texas Instruments. UNIX is a registered trademark of UNIX System Laboratories. All other trademarks are the property of their respective owners. Documentation matters. 2 Apple DocViewer queries. What’s on your mind? 4 Asynchronous Routines on the Macintosh by Jim Luther How to avoid the pitfalls of calling routines asynchronously. 5 Inside QuickTime and Component-Based Managers by Bill Guschwan Useful debugging and tracing techniques for QuickTime and the Component Manager. 34 Macintosh Debugging: The Belly of the Beast Revisited by Fred Huxham and Greg Marriott A supplement to the Belly of the Beast debugging article in Issue 8: four new tools explained. 54 Adventures in Color Printing by Dave Hersey A general strategy for printing color images that ensures the best possible quality. 64 DeviceLoop Meets the Interface Designer by John Powers This little- known System 7 routine can help you deal with multiple screen environments. 97 Somewhere in QuickTime: Top 10 QuickTime Tips by John Wang The first installment of a new column on QuickTime: hot tips from the masters. 31 Print Hints: Looking Ahead to QuickDraw GX by Pete (“Luke”) Alexander Some things you should be aware of involving QuickDraw GX and its effect on printing. 52 The Veteran Neophyte: Tower of Babble by Dave Johnson Programming languages are just like natural languages, only different. 61 Graphical Truffles: The Palette Manager Way by Edgar Lee and Forrest Tanaka The Palette Manager need not be a mystery. Here’s the scoop. 91 KON & BAL’s Puzzle Page: Booting Blues by Konstantin Othmer and Bruce Leak Yet another elusive crasher bug that you’ll never guess in a million years. 118 Macintosh Q & A Apple’s Developer Support Center answers your product development questions. 104 122 I N D E X Q & A C O L U M N S A R T I C L E S L E T T E R S E D I T O R I A L

Reading notes: Possible misspelling 'Coporation' in trademark notice as printed

Printed product names
Apple DocViewer · QuickTime · QuickDraw GX · Macintosh · HyperCard · MacWrite · ImageWriter · LaserWriter · StyleWriter · Apple IIGS · AppleShare · AppleTalk · MacApp · MPW · MultiFinder · ProDOS · SANE · TrueType · PostScript · System 7 · ColorSync · PowerBook · QuickDraw · Sound Manager · Finder · MoviePlayer · PhotoGrade · NuBus · UNIX · AppleLink · APDA · AppleGlot · develop · Moof · DocViewer
Printed dates
March 1993 · © 1993
Languages
English
PDF page 4

Dear Readers, In May of last year, I schmoozed with a lot of developers at Apple’s Worldwide Developer’s Conference, and one of the subjects that came up was documentation. I expressed my ideas on this subject somewhat hesitantly, because I thought the truths I was spouting were all pretty obvious, but I was surprised to find that several developers seemed enlightened by them and even suggested this as a topic for a develop editorial. So here goes. But first, some motivation. If you’re one of those developers who think no one reads manuals anyway, has it occurred to you that this might be a self-fulfilling prophecy? If manuals were better, maybe people would read them. Also, customers who do never read the manual will never learn the full power of your product (probably not every feature is self-explanatory) and will be that much quicker to move on when someone shows them the great things a rival product can do. More likely, people glance at the manual to get started and then thumb through it later when they want to explore certain features. Also keep in mind that a shoddy manual will be seen as a reflection of the product as a whole: “If this is the best they could do on the manual, how good can their software be?” Don’t fool yourself that only writers or editors will criticize a poorly done manual; any reader who has trouble learning from it will complain, and not just to themselves. While there are times when consistency may be the hobgoblin of small minds, it’s often the case that inconsistent presentation or terminology will confuse readers and have them throwing your manual down in disgust and thinking your product is more complicated than it really is. And people who do know things like the difference between “its” and “it’s” will wonder how well you debugged your code if you couldn’t find mistakes like this in your manual. Basically, you won’t look like a class act. I’ll state the following points with user documentation in mind, though most of them also apply to technical documentation for developers. Some points may be useful only to small companies, but there should be something here for everyone. • Get a technical writer to write your documentation. Don’t do it yourself — and try to talk the CEO or VP of Marketing out of doing it. Contrary to many people’s opinions, writing a manual is d e v e l o p March 1993 CAROLINE ROSE (AppleLink CROSE) has been writing and editing software documentation since many of you were rug rats. She began at a timesharing company, joined Apple in 1982 to write Inside Macintosh, and helped get NeXT off the ground in 1986. Back at Apple now, she has seven issues of develop under her belt and is still having a wonderful time. A transplanted New Yorker, Caroline visited the East Coast last October in time to see the leaves turn colors. She enjoyed doing the theater and museum thing in Manhattan and hitting some incredible restaurants and nightclubs — not to mention a deli whose smoked mozarella is the best this side of Naples. But the highlight was her visit to a friend’s farm in Connecticut (sheep feeding beats sheet feeding any day!). Walking to an apple orchard and tasting fresh sweet cider was sheer rural bliss.• 2 CAROLINE ROSE

Reading notes: Headline not clearly identifiable; opening is a letter salutation 'Dear Readers,' Some running headers and line breaks in the source make reading order slightly uncertain

Printed product names
Inside Macintosh · develop · NeXT
Printed dates
May of last year · March 1993 · 1982 · 1986 · October
Languages
English
PDF page 5

not something any smart person can do; it’s a skill like any other. Most likely you are no more qualified to write the documentation than a writer is qualified to write your code. • Look over a relevant writing sample from your prospective writer. Awards, certificates, and years of experience go only so far: nothing will tell you whether you’ll get a good manual as much as looking at past work. Ask how the material for the sample was gathered, who else contributed to it, and how heavily it was edited. • Get the writer started early in the process — long before the feature set is frozen. Writers provide a valuable perspective of your product, not unlike that of product management. They’ll help with the design of the product, telling you what features don’t fit in with other ones and pointing out loopholes, inconsistencies, and other Bad Things. And they’re typically excellent bug finders. • Have the documentation edited by an editor. Unless they also happen to be editors, writers need their work checked like anyone else — and an electronic spelling or grammar check (while a good start) isn’t enough. • Test the result on users, after your product ships if not sooner (you can revise the documentation for the next printing). And don’t be defensive: if only one out of ten “testers” turns up a particular problem, it may mean that 10% of your user base will have the same problem. Judge no misunderstanding as stupid; they’re all valid, no matter how much you may disagree with them. I could go on forever, but that’s enough for now. Please make my day and let me know if you got anything of value out of this. Or criticize it if you like; I can use the practice in not being defensive. Caroline Rose Editor EDITORIAL March 1993 3 SUBSCRIPTION INFORMATION To subscribe to develop, use the subscription card in the back of this issue. Please address all subscription-related inquiries to develop, Apple Computer, Inc., P.O. Box 531, Mt. Morris, IL 61054 (or AppleLink DEV.SUBS).• BACK ISSUES For information about back issues of develop and how to obtain them, see the last page of this issue. Back issues are also on the Developer CD Series disc.•

Reading notes: Source text begins mid-sentence and the sequence of the editorial passage relative to the subscription and back-issue notices is uncertain.

Printed product names
develop · Developer CD Series · AppleLink DEV.SUBS
Printed dates
March 1993
Languages
English
PDF page 6

TECH NOTES: WORD IS OUT Why are the Tech Notes in Microsoft Word documents? Are you assuming all developers have Microsoft Word? I don’t think this is a good assumption. Developers who don’t have Microsoft Word would be required to either purchase it or get an illegal copy. Or I suppose they might be able to use their favorite word processor and convert the Tech Notes if such converters exist. Big developers may have the capital to purchase Microsoft Word but small or starting developers may not, especially those enthusiastic and creative programmers in school. It would be a shame to force them to get an illegal copy of Microsoft Word so that they could learn the same wonderful magic tricks that others get from the Tech Notes. Is it possible to produce the Tech Notes in a minimal text editor such as TeachText or DocMaker? Or better yet, why not use Apple DocViewer like the N ew Inside M acintosh documents? — Hoon Im T his is a timely question, as the format of Tech N otes on the CD has changed. But first, some background. T here are several reasons why we distributed Tech N otes as M icrosoft Word documents. Internally we use M icrosoft Word as the authoring tool for Tech N otes because of its relatively powerful formatting abilities and ease of use. It also turns out that most word processing packages, such as M acW rite ® II, have translators that do a reasonable job on M icrosoft Word documents, so most people have access to the information. We’re firmly against pirating software! Also, our primary commitment has been to providing the highest quality technical material possible; rather than focusing on format conversion, we chose to improve the overall content and organization of the Tech N otes. Only then were we ready to turn our full attention to the question of format. You mention Apple DocViewer as a possible alternative format — we have in fact converted the Tech N otes into Apple DocViewer format (take a look on the CD). Over time this will be improved to provide better indexing and cross-reference facilities — whose absence we’ve been painfully aware of in the M icrosoft Word format. — N eil Day, Tech N ote Pooh-Bah LICENSING DOCVIEWER We are a long-time Macintosh educational software developer. We’ve traditionally converted our printed documentation to HyperCard® for on- line use by our customers. I wondered to whom we should speak to request developer licensing of Apple DocViewer? —Rhett Tindall Apple DocViewer documents are sourced from several word processors. T hese documents must be processed in another application before they become DocViewer documents. T his application is currently not of commercial quality and is for Apple internal use only. However, we’re in the process of investigating whether to refine the application and make it available outside Apple. T his process may take some time and may not result in providing the software to external parties. Please stay tuned! — In-Yung Kim d e v e l o p March 1993 GIVE US A PIECE OF YOUR MIND We welcome timely letters to the editors, especially from readers reacting to articles that we publish in develop. Letters should be addressed to Caroline Rose (or, if technical develop-related questions, to Dave Johnson) at Apple Computer, Inc., 20525 Mariani Avenue, M/S 75-2B, Cupertino, CA 95014 (AppleLink CROSE or JOHNSON.DK). All letters should include your name and company name as well as your address and phone number. Letters may be excerpted or edited for clarity (or to make them say what we wish they did).• 4 LETTERS

Reading notes: Interleaved column text and OCR spacing make the reading order of some passages uncertain. Some product names appear with inconsistent spacing, such as 'N ew Inside M acintosh' and 'M acW rite ®'.

Printed product names
Microsoft Word · TeachText · DocMaker · Apple DocViewer · HyperCard · AppleLink · develop
Printed dates
March 1993
Languages
English
PDF page 7

T he M acintosh has always supported asynchronous calls to many parts of its operating system. T his article expands on the information found in Inside M acintosh by telling when, why, and how you should use functions asynchronously on the M acintosh. It includes debugging hints and solutions to problems commonly encountered when asynchronous calls are used. When calling a routine synchronously, your program passes control to the routine and doesn’t continue execution until the routine’s work has completed (either successfully or unsuccessfully). This would be like giving someone a task and then watching them perform that task. Although the task is eventually completed, you don’t get anything done while you watch. On the other hand, when calling a routine asynchronously, your program passes control to the routine, and the program’s request is placed in a queue or, if the queue is empty, executed immediately; in either case, control returns to the program very quickly, even if the request can’t be executed until later. The system processes any queued requests while your program is free to continue execution, then interrupts you later when the request is completed. This is like giving someone a task and going back to your work while they finish the task. In most cases, it results in more work being accomplished during the same period of time. Figure 1 illustrates the difference between synchronous and asynchronous calls. One situation in which you shouldn’t use synchronous calls is when you don’t know how long it may take for the operation to complete, as with the PPC Toolbox’s PPCInform function, for example. PPCInform won’t complete until another program attempts to start a session with your program. This could happen immediately, but the chances are far greater that it won’t. If PPCInform is called synchronously, it appears that the system has locked up because the user won’t get control back until the call completes. If you call PPCInform asynchronously, it doesn’t matter if the function doesn’t complete for minutes, hours, or even days — your program (and the rest of the system) can continue normally. ASYNCHRONOUS ROUTINES ON THE MACINTOSH March 1993 5 JIM LUTHER works in Apple Developer Technical Support, focusing on AppleTalk, the File Manager, and other lower regions of the operating system. Jim uses a heap/stack-based organizational model in his office: there are heaps or stacks of books, papers, disks, and hardware on every square inch of shelf space and over most of the floor. He was last seen muttering to himself “Now where did I put that . . .?”• JIM LUTHER ASYNCHRONOUS ROUTINES ON THE MACINTOSH

Reading notes: Byline and sidebar text appear interleaved with main article text, so reading order may be uncertain.

Printed product names
PPC Toolbox · PPCInform
Printed dates
March 1993
Languages
English
PDF page 8

You should also avoid synchronous calls when you can’t know the state of the service you’ve asked for. Program code that’s part of a completion routine, VBL task, Time Manager task, Deferred Task Manager task, or interrupt handler is executed at what’s commonly called interrupt time . Synchronous calls made at interrupt time often result in deadlock. (See “Deadlock.”) An asynchronous call can solve the problem: if the service you call is busy handling another request, your asynchronous request is queued and your program code can give up control (that is, the completion routine or task your code is part of can end), letting the service complete the current request and eventually process your request. Routines called synchronously are allowed to move memory, while routines called asynchronously purposely avoid moving memory so that they can be called at interrupt time. For example, the File Manager’s PBHOpen routine may move memory when called synchronously, but won’t when called asynchronously. If your code is executing in an environment where memory can’t be moved (for example, at interrupt time), you must call routines asynchronously to ensure that they don’t move memory. At this time, the various lists in Inside M acintosh of “Routines That May Move or Purge Memory,” “Routines and Their Memory Behavior,” and “Routines That d e v e l o p March 1993 6 Synchronous call Operating system Operating system Response Asynchronous call Application code Application code Time Time Response/Control Request/Control Interrupt Control Request/Control Figure 1 How Synchronous and Asynchronous Calls Work

Reading notes: Running page header 'develop March 1993' is interleaved with body text Figure 1 diagram labels are fragmented and their reading order is uncertain

Printed dates
March 1993
Languages
English
PDF page 9

Should Not Be Called From Within an Interrupt” are either incomplete or incorrect and can’t be trusted entirely. The reasons why a system routine can’t be called at interrupt time include: the routine may move memory; the routine may cause a deadlock condition; the routine is not reentrant. This article shows how to postpone most system calls until a safe time. You’re encouraged to call as few system routines at interrupt time as possible. The routines discussed in this article are low-level calls to the File Manager, the Device Manager (including AppleTalk driver, Serial Driver, and disk driver calls), and the PPC Toolbox. All these routines take the following form: FUNCTION SomeFunction (pbPtr: aParamBlockPtr; async: BOOLEAN): OSErr; Routines of this form are executed synchronously when async = FALSE or asynchronously when async = TRUE. ASYNCHRONOUS ROUTINES ON THE MACINTOSH March 1993 7 Deadlock is a state in which each of two or more processes is waiting for one of the other processes to release some resource necessary for its completion. The resource may be a file, a global variable, or even the CPU. The process could, for example, be an application’s main event loop or a Time Manager task. When deadlock occurs on the Macintosh, usually at least one of the processes is executing as the result of an interrupt. VBL tasks, Time Manager tasks, Deferred Task Manager tasks, completion routines, and interrupt handlers can all interrupt an application’s main thread of execution. When the interrupted process is using a resource that the interrupting process needs, the processes are deadlocked. For example, suppose a Time Manager task periodically writes data to a file by making a synchronous Write request, and an application reads the data from its main event loop. Depending on the frequency of the task and the activity level of the File Manager, the Time Manager task may often write successfully. Inevitably, however, the Time Manager task will interrupt the application’s Read request and deadlock will occur. Because the File Manager processes only one request at a time, any subsequent requests must wait for the current request to complete. In this case, the synchronous request made by the Time Manager task must wait for the application’s Read request to complete before its Write request will be processed. Unfortunately, the File Manager must wait for the Time Manager task to complete before it can resume execution. Each process is now waiting for the other to complete, and they’ll continue to wait forever. Synchronous requests at interrupt time tend to produce deadlock, because the call is queued for processing and then the CPU sits and spins, waiting for an interrupt to occur, which signals that the request has been completed. If interrupts are turned off, or if a previous pending request can’t finish because it’s waiting to resume execution after the interrupt, the CPU will wait patiently (and eternally) for the request to finish — until you yank the power cord from the wall. DEADLOCK BY GORDON SHERIDAN

Printed dates
March 1993
Languages
English
PDF page 10

DETERMINING ASYNCHRONOUS CALL COMPLETION Your program can use two methods to determine when an asynchronous call has completed: periodically poll for completion (check the ioResult field of the parameter block passed to the function) or use a completion routine. Both methods enable your program to continue with other operations while waiting for an asynchronous call to complete. POLLING FOR COMPLETION Polling for completion is a simple method to use when you have only one or two asynchronous calls outstanding at a time. It’s like giving someone a task and calling them periodically to see if they’ve completed it. When your program fills in the parameter block to pass to the function, it sets the ioCompletion field to NIL, indicating that there’s no completion routine. Then, after calling the function asynchronously, your program only needs to poll the value of the ioResult field of the parameter block passed to the function and wait for it to change: • A positive value indicates the call is either still queued or in the process of executing. • A value less than or equal to 0 (noErr) indicates the call has completed (either with or without an error condition). Polling is usually straightforward and simple to implement, which makes the code used to implement polling easy to debug. The following code shows an asynchronous PPCInform call and how to poll for its completion: PROCEDURE MyPPCInform; VAR err: OSErr; { Error conditions are ignored in this procedure } { because they are caught in PollForCompletion. } BEGIN gPPCParamBlock.informParam.ioCompletion := NIL; gPPCParamBlock.informParam.portRefNum := gPortRefNum; gPPCParamBlock.informParam.autoAccept := TRUE; gPPCParamBlock.informParam.portName := @gPPCPort; gPPCParamBlock.informParam.locationName := @gLocationName; gPPCParamBlock.informParam.userName := @gUserName; err := PPCInform(PPCInformPBPtr(@gPPCParamBlock), TRUE); END; In this code, MyPPCInform calls the PPCInform function asynchronously with no completion routine (ioCompletion is NIL). The program can then continue to do other things while periodically calling the PollForCompletion procedure to find out when the asynchronous call completes. d e v e l o p March 1993 8

Printed dates
March 1993
Languages
English
PDF page 11

PROCEDURE PollForCompletion; BEGIN IF gPPCParamBlock.informParam.ioResult <= noErr THEN BEGIN { The call has completed. } IF gPPCParamBlock.informParam.ioResult = noErr THEN BEGIN { The call completed successfully. } END ELSE BEGIN { The call failed, handle the error. } END; END; END; PollForCompletion checks the value of the ioResult field to find out whether PPCInform has completed. If the call has completed, PollForCompletion checks for an arror condition and then performs an appropriate action. There are three important things to note in this example of polling for completion: • The parameter block passed to PPCInform, gPPCParamBlock, is a program global variable. Since the parameter block passed to an asynchronous call is owned by the system until the call completes, the parameter block must not be declared as a local variable within the routine that makes the asynchronous call. The memory used by local variables is released to the stack when a routine ends, and if that part of the stack gets reused, the parameter block, which could still be part of an operating system queue, can get trashed, causing either unexpected results or a system crash. Always declare parameter blocks globally or as nonrelocatable objects in the heap. • Calls to PollForCompletion must be made from a program loop that’s not executed completely at interrupt time. This prevents deadlock. You don’t necessarily have to poll from an application’s event loop (which is executed at noninterrupt time), but if you poll from code that executes at interrupt time, that code must give up control between polls. • PollForCompletion checks the ioResult field of the parameter block to determine whether PPCInform completed and, if it completed, to see if it completed successfully. One drawback to polling for completion is latency. When the asynchronous routine completes its job, your program won’t know it until the next time you poll. This can be wasted time. For example, assume you give someone a task and ask them if they’re done (poll) only once a day: if they finish the task after an hour, you won’t find out ASYNCHRONOUS ROUTINES ON THE MACINTOSH March 1993 9

Reading notes: Source contains Pascal-style code with OCR-like spacing artifacts; 'arror' appears to be a typo for 'error' in the body text

Printed dates
March 1993
Languages
English