FTAM/9000 Programmer's Guide
Chapter 4 179
Using Support Functions
Responding to Asynchronous Calls
Following is an example of the use of em_wait(). This example creates
and opens a file by asynchronously calling ft_bgroup(), ft_create(), and
ft_open(), followed by synchronously calling ft_egroup(). These functions
were called with return_event_names of 1, 2, 3, and 0, respectively. The
em_wait() function waits on these calls.
struct Ft_bgroup_out_dcb *bgr_inout_dcb;
struct Ft_create_out_dcb *cre_inout_dcb;
struct Ft_open_out_dcb *ope_inout_dcb;
Em_t time;
Local_event_name return_event_name;
Api_rc result;
int i;
Return_code res;
struct Ft_diagnostic *diag = NULL;
/* This loop waits on the three previously submitted
asynchronous calls. */
for (i = 1; i %<= 3; ++i) {
time = -1;
/* Call em_wait() to receive the latest event. */
res = em_wait(time, & return_event_name, & result);
if (res != SUCCESS)
error_handler(result, diag);
/* Check the result of each function. */
switch (return_event_name) {
case 1:
if (bgr_inout_dcb->result.return_code != SUCCESS)
error_handler(bgr_inout_dcb->result, diag);
break;
case 2:
if (cre_inout_dcb->result.return_code != SUCCESS)
error_handler(cre_inout_dcb->result,
cre_inout_dcb->diagnostic);
break;
case 3:
if (ope_inout_dcb->result.return_code != SUCCESS)
error_handler(ope_inout_dcb->result,
ope_inout_dcb->diagnostic);
break;
default:
break;
}
}