gs_wait.c

Go to the documentation of this file.
00001 
00007 /* $Id: gs_wait.c,v 1.4 2007/03/01 22:52:31 seymour Exp $ */
00008 /* $UTK_Copyright: $ */
00009 
00010 #include <stdio.h>
00011 
00012 #include "idl_export.h"
00013 #include "grpc.h"
00014 #include "idl_request.h"
00015 
00028 IDL_VPTR
00029 gs_wait(int argc, IDL_VPTR* argv_idl)
00030 {
00031   grpc_function_handle_t *handle = NULL;
00032   grpc_error_t info;
00033   int req_id;
00034 
00035   IDL_ENSURE_SCALAR(argv_idl[0]);
00036 
00037   req_id = IDL_LongScalar(argv_idl[0]);
00038 
00039   /* Initialize GridRPC system */
00040   info = grpc_initialize(NULL);
00041   if((info != GRPC_NO_ERROR) && (info != GRPC_ALREADY_INITIALIZED)) {
00042     IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, "Error: cannot initialize!");
00043     return IDL_GettmpLong((int)info);
00044   }
00045 
00046   IDL_TimerBlock(IDL_TRUE);
00047 
00048   /* must be before grpc_wait(). */
00049   if(grpc_get_handle(&handle, req_id) != GRPC_NO_ERROR)
00050     IDL_Message(IDL_M_GENERIC,IDL_MSG_INFO,
00051          "Warning: gs_wait() cannot get function handle!");
00052 
00053   info = grpc_wait(req_id);
00054 
00055   IDL_TimerBlock(IDL_FALSE);
00056 
00057   if(info == GRPC_NO_ERROR)
00058     del_req(req_id);    
00059 
00060   if(handle) {
00061     grpc_function_handle_destruct(handle);
00062     free(handle);
00063   }
00064 
00065   return IDL_GettmpLong((int)info);
00066 }