#include <oct.h>
#include <stdio.h>
#include <stdlib.h>
#include "grpc.h"
#include "gs_oct.h"
Go to the source code of this file.
Functions | |
DEFUN_DLD (gs_cancel, args, nargout,"Octave client for GridSolve") |
DEFUN_DLD | ( | gs_cancel | , | |
args | , | |||
nargout | , | |||
"Octave client for GridSolve" | ||||
) |
Definition at line 22 of file gs_cancel.cpp.
{ octave_value_list bad_retval; //bad return value grpc_error_t status; //GridRPC status/error code grpc_sessionid_t req_id; //GridRPC non-blocking call session id //meaningless return value for error condition //or those calls that do not make grpc function call for (int i = 0; i < nargout; i++) { bad_retval(i) = Matrix(0, 0); } //number of input arguments int nargin = args.length(); //input argument error checking if (nargin <= 0) { fprintf(stderr, "No input service name found. Aborted.\n"); return bad_retval; } if (nargin > 1) { fprintf(stderr, "Exactly one argument (session id) is expected. Aborted.\n"); return bad_retval; } //otherwise, the input is correct //initialize the GridSolve environment status = grpc_initialize(NULL); if (status != GRPC_NO_ERROR && status != GRPC_ALREADY_INITIALIZED) { fprintf(stderr, "%s\n", grpc_error_string(status)); return bad_retval; } //the GRPC session id req_id = args(0).int_value(); //cancel the job status = grpc_cancel(req_id); if (status != GRPC_NO_ERROR) { fprintf(stderr, "%s\n", grpc_error_string(status)); return bad_retval; } //finalize and clean up grpc_finalize(); return octave_value(status); }