Guardian Programmer's Guide

Table Of Contents
Using Nowait Input/Output
Guardian Programmer’s Guide 421922-014
4 - 6
Completing I/Os in the Order Initiated
This subsection discusses both of these approaches.
In both of these approaches, the AWAITIO[X] call can wait indefinitely, time out, or
check for completion and return immediately, exactly as in the single-I/O single-file
model discussed in the previous subsection. (When a timeout expires, only the oldest
I/O operation is canceled.)
Completing I/Os in the Order Initiated
The following example uses nowait I/O to start several I/O operations. In this case,
calls to the AWAITIOX procedure complete the operations in the order they started.
NOWAIT^DEPTH := 4;
ERROR := FILE_OPEN_(PROCESSNAME:LENGTH,
F4,
!access!,
!exclusion!,
NOWAIT^DEPTH);
IF ERROR <> 0 THEN ...
.
.
.
BYTES := 10;
LENGTH := 512;
CALL WRITEREADX(F4,BUFFER1,BYTES,LENGTH);
IF <> THEN ...
BYTES := 25;
LENGTH := 512;
CALL WRITEREADX(F4,BUFFER2,BYTES,LENGTH);
IF <> THEN ...
BYTES := 12;
LENGTH := 512;
CALL WRITEREADX(F4,BUFFER3,BYTES,LENGTH);
IF <> THEN ...
.
.
.
CALL AWAITIOX(F4);
IF <> THEN ...
CALL AWAITIOX(F4);
IF <> THEN ...
CALL AWAITIOX(F4);
IF <> THEN ...
The FILE_OPEN_ call sets the nowait depth to 4, allowing up to four nowait operations
to run concurrently against the file. The program then issues three WRITEREADX
operations against the file and continues processing. Finally, the program issues three
calls to the AWAITIOX procedure. The first call completes the operation started by the
first WRITEREADX call, the second AWAITIOX call completes the operation started by
the second WRITEREADX call, and so on.