# develop-13 9313 March 1993 — source transcripts, page 2

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-develop-13-9313-march-1993-1fc05d/2)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### PDF page 12

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-13-9313-march-1993-1fc05d/2#scan-a0075eef080e8e6fc4a883a61b7794aea154050b58297f0c5e04aa7e4e16a079)

Transcribed text:

they’ve completed the task until 23 hours later (a 23-hour latency). To avoid latency,
use completion routines instead of polling ioResult to find out when a routine
completes.
USING COMPLETION ROUTINES
Making an asynchronous call with a completion routine is only slightly more complex
than polling for completion. A completion routine is a procedure that’s called as soon
as the asynchronous function completes its task. When your program fills in the
parameter block to pass to the function, it sets the ioCompletion field to point to the
completion routine. Then, after calling the function asynchronously, your program
can continue. When the function completes, the system interrupts the program that’s
running and the completion routine is executed. (There are some special things you
need to know about function results to use this model; see “Function Results and
Function Completion.”)
Since the completion routine is executed as soon as the function’s task is complete,
your program finds out about completion immediately and can start processing the
results of the function. Using a completion routine is like giving someone a task and
then asking them to call you as soon as they’ve completed it.
Because a completion routine may be called at interrupt time, it can’t assume things
that most application code can. When a completion routine for an asynchronous
function gets control, the system is in the following state:
•   On entry, register A0 points to the parameter block used to make
the asynchronous call.
d e v e l o p   March 1993
10
Not all function results are equal. Ignore some, pay
attention to others. Ignore function results from
asynchronous File Manager and PPC Toolbox calls. They
contain no useful information. To get useful result
information, wait for the call to complete, then check
ioResult or register D0; both contain the result.
Both the File Manager and the PPC Toolbox will always
call your completion routine if you specified one. If you
didn’t supply one, and instead are polling, test ioResult in
your parameter block. The call has completed if ioResult is
less than or equal to noErr.
Don’t ignore function results from asynchronous Device
Manager calls (for example, AppleTalk driver, Serial
Driver, and disk driver calls). The function result tells you
whether the Device Manager successfully delivered your
request to the device driver. Success is indicated by noErr;
any other value indicates failure.
The system calls your completion routine only if the Device
Manager successfully delivered your request to the driver.
On completion, check whether your call succeeded by
looking in ioResult or register D0.
FUNCTION RESULTS AND FUNCTION COMPLETION
BY SCOTT BOYD AND JIM LUTHER

Reading notes: Page number '10' and running header text appear mid-passage; reading order around the sidebar block is uncertain.

Printed dates: March 1993

Languages: English

[Original PDF page 12](https://www.vintageapple.net/files/57283aa964ea99049ebddf25800339b5dfc549e1a6dc0d9c88d98b3350b039ed/develop-13_9313_March_1993.pdf#page=12)

[Previous transcribed scans](https://www.vintageapple.net/transcripts/media/va-develop-13-9313-march-1993-1fc05d/1.md)
