Go to the documentation of this file.00001
00007
00008
00009
00010 #include <stdio.h>
00011 #include <string.h>
00012
00013 #include <matrix.h>
00014 #include <mex.h>
00015
00016 #include "grpc.h"
00017 #include "comm_data.h"
00018 #include "matlab_gs.h"
00019
00031 void
00032 matlab_gs_wait( int nlhs, mxArray *plhs[],
00033 int nrhs, const mxArray *prhs[] )
00034 {
00035 int i = -1;
00036 int rc = -1;
00037 grpc_request_t *request = NULL;
00038 grpc_sessionid_t sessionID;
00039 grpc_error_t status;
00040
00041
00042 matlab_gs_error_num = 0;
00043
00044
00045 if (nrhs < 2) {
00046 mexErrMsgTxt("Usage: [outputargs,...] = gs_wait(sessionID, inputargs, ...)\n");
00047 for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);
00048 DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
00049 }
00050
00051
00052 sessionID = (int)mxGetPr(prhs[1])[0];
00053 if (sessionID < 0) DO_ERROR_MACRO(GRPC_INVALID_SESSION_ID);
00054
00055
00056 if (grpc_set_client_major("Column") != GRPC_NO_ERROR)
00057 DO_ERROR_MACRO(grpc_errno);
00058
00059
00060 request = grpc_get_request(sessionID);
00061 if (request == NULL) DO_ERROR_MACRO(grpc_errno);
00062
00063
00064
00065
00066
00067
00068
00069 status = gs_wait_common(request);
00070 if (status != GRPC_NO_ERROR) DO_ERROR_MACRO(grpc_errno);
00071
00072
00073 rc = matlab_gs_get_output(request->problem, nlhs, plhs, nrhs, prhs);
00074 if (rc != 0) DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
00075
00076
00077 DBGPRINTF("Clean up\n");
00078 if (matlab_gs_free_args(request->handle->problem_desc, nlhs, plhs, nrhs, prhs) != 0) DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
00079 if (request && request->handle) if (grpc_function_handle_destruct(request->handle) != GRPC_NO_ERROR) DO_ERROR_MACRO(grpc_errno);
00080 if (request && request->handle) request->handle = matlab_gs_free(request->handle);
00081 if (grpc_request_destruct_free_clear(sessionID) != GRPC_NO_ERROR) DO_ERROR_MACRO(grpc_errno);
00082
00083
00084 return;
00085
00086
00087
00088 error:
00089 for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);
00090 mexPrintf("Warning: GridSolve call failed: %d:%d: %s; %s\n", grpc_errno, grpc_minor_errno, grpc_error_string(grpc_errno), grpc_minor_error_string(grpc_minor_errno));
00091
00092
00093 return;
00094 }
00095