Functions

matlab_gs_cancel.c File Reference

#include <stdio.h>
#include <string.h>
#include <matrix.h>
#include <mex.h>
#include "grpc.h"
#include "matlab_gs.h"
Include dependency graph for matlab_gs_cancel.c:

Go to the source code of this file.

Functions

void matlab_gs_cancel (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

Detailed Description

Matlab client call

Definition in file matlab_gs_cancel.c.


Function Documentation

void matlab_gs_cancel ( int  nlhs,
mxArray *  plhs[],
int  nrhs,
const mxArray *  prhs[] 
)

Cancel an asynchronous call and returns the status of the grpc_cancel (i.e. O on OK or -1 on error).

Parameters:
nlhs - Number of left hand side arguments from Matlab
plhs - Pointer to left hand side arguments from Matlab
rlhs - Number of right hand side arguments from Matlab
plhs - Pointer to right hand side arguments from Matlab

Definition at line 34 of file matlab_gs_cancel.c.

{
  int i;
  grpc_sessionid_t sessionID;
  int retval;

  /* reset global error setting */
  matlab_gs_error_num = 0;  

  /* Check arguments */
  if (nrhs != 2 || nlhs != 1) {
    mexErrMsgTxt("Usage: status = gs_cancel(sessionId)\n");
    DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
  }

  /* Get sessionid from rhs */
  sessionID = (int)mxGetPr(prhs[1])[0];
  if (sessionID < 0) {
    matlab_gs_error_num = GRPC_OTHER_ERROR_CODE;
    DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
  }

  /* Call cancel */
  retval = grpc_cancel(sessionID);
  if (retval != GRPC_NO_ERROR) DO_ERROR_MACRO(grpc_errno);

  /* If OK, output result, else error */
  plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
  mxGetPr(plhs[0])[0] = (double)retval;

  return; 



 error:
  /* Create blank output for left hand side */ 
  plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
  mxGetPr(plhs[0])[0] = (double)-1;
  for (i=1;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);

  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));  

  return;

}

Here is the call graph for this function:

Here is the caller graph for this function: