Mercury
Functions
mercury.h File Reference
#include "mercury_types.h"
Include dependency graph for mercury.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HG_EXPORT hg_return_t HG_Version_get (unsigned int *major, unsigned int *minor, unsigned int *patch)
 Get Mercury version number. More...
 
HG_EXPORT hg_return_t HG_Init (na_class_t *na_class)
 Initialize the Mercury layer. More...
 
HG_EXPORT hg_return_t HG_Finalize (void)
 Finalize the Mercury layer. More...
 
HG_EXPORT hg_return_t HG_Initialized (hg_bool_t *flag, na_class_t **na_class)
 Indicate whether HG_Init has been called and return associated network class. More...
 
HG_EXPORT hg_id_t HG_Register (const char *func_name, hg_proc_cb_t in_proc_cb, hg_proc_cb_t out_proc_cb, hg_rpc_cb_t rpc_cb)
 Register a function name that can be sent using the RPC layer. More...
 
HG_EXPORT hg_return_t HG_Registered (const char *func_name, hg_bool_t *flag, hg_id_t *id)
 Indicate whether HG_Register has been called and return associated ID. More...
 
HG_EXPORT hg_return_t HG_Forward (na_addr_t addr, hg_id_t id, void *in_struct, void *out_struct, hg_request_t *request)
 Forward a call to a remote server. More...
 
HG_EXPORT hg_return_t HG_Wait (hg_request_t request, unsigned int timeout, hg_status_t *status)
 Wait for an operation request to complete. More...
 
HG_EXPORT hg_return_t HG_Wait_all (int count, hg_request_t array_of_requests[], unsigned int timeout, hg_status_t array_of_statuses[])
 Wait for all operations in array_of_requests to complete. More...
 
HG_EXPORT hg_return_t HG_Request_free (hg_request_t request)
 Free request and resources allocated when decoding the output. More...
 
HG_EXPORT const char * HG_Error_to_string (hg_return_t errnum)
 Convert error return code to string (null terminated). More...
 

Function Documentation

HG_EXPORT hg_return_t HG_Version_get ( unsigned int *  major,
unsigned int *  minor,
unsigned int *  patch 
)

Get Mercury version number.

Parameters
major[OUT] pointer to unsigned integer
minor[OUT] pointer to unsigned integer
patch[OUT] pointer to unsigned integer
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Init ( na_class_t na_class)

Initialize the Mercury layer.

Calling HG_Init also calls HG_Bulk_init with the same NA class if HG_Bulk_init has not been called before, this allows users to eventually initialize the bulk interface with a different NA class.

Parameters
na_class[IN] pointer to network class
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Finalize ( void  )

Finalize the Mercury layer.

Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Initialized ( hg_bool_t *  flag,
na_class_t **  na_class 
)

Indicate whether HG_Init has been called and return associated network class.

Parameters
flag[OUT] pointer to boolean
na_class[OUT] pointer to returned network class pointer
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_id_t HG_Register ( const char *  func_name,
hg_proc_cb_t  in_proc_cb,
hg_proc_cb_t  out_proc_cb,
hg_rpc_cb_t  rpc_cb 
)

Register a function name that can be sent using the RPC layer.

Parameters
func_name[IN] unique name associated to function
in_proc_cb[IN] pointer to input proc routine
out_proc_cb[IN] pointer to output proc routine
rpc_cb[IN] RPC callback (may only be defined in server code)
Returns
unique ID associated to the registered function
HG_EXPORT hg_return_t HG_Registered ( const char *  func_name,
hg_bool_t *  flag,
hg_id_t id 
)

Indicate whether HG_Register has been called and return associated ID.

Parameters
func_name[IN] name associated to function
flag[OUT] pointer to boolean
id[OUT] pointer to ID
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Forward ( na_addr_t  addr,
hg_id_t  id,
void *  in_struct,
void *  out_struct,
hg_request_t request 
)

Forward a call to a remote server.

Request must be freed using HG_Request_free.

Parameters
addr[IN] abstract network address of destination
id[IN] registered function ID
in_struct[IN] pointer to input structure
out_struct[OUT] pointer to output structure
request[OUT] pointer to RPC request
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Wait ( hg_request_t  request,
unsigned int  timeout,
hg_status_t status 
)

Wait for an operation request to complete.

Once the request has completed, request must be freed using HG_Request_free.

Parameters
request[IN] RPC request
timeout[IN] timeout (in milliseconds)
status[OUT] pointer to returned status
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Wait_all ( int  count,
hg_request_t  array_of_requests[],
unsigned int  timeout,
hg_status_t  array_of_statuses[] 
)

Wait for all operations in array_of_requests to complete.

Parameters
count[IN] number of RPC requests
array_of_requests[IN] arrays of RPC requests
timeout[IN] timeout (in milliseconds)
array_of_statuses[OUT] array of statuses
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t HG_Request_free ( hg_request_t  request)

Free request and resources allocated when decoding the output.

User must get output parameters contained in the output structure before calling HG_Request_free.

Parameters
request[IN] RPC request
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT const char* HG_Error_to_string ( hg_return_t  errnum)

Convert error return code to string (null terminated).

Parameters
errnum[IN] error return code
Returns
String