Mercury
Typedefs | Functions
mercury_request.h File Reference
#include "mercury_util_config.h"
Include dependency graph for mercury_request.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct hg_request_class hg_request_class_t
 Purpose: define a request emulation library on top of the callback model that uses progress/trigger functions. More...
 
typedef struct hg_request_object hg_request_object_t
 
typedef int(* hg_request_progress_func_t )(unsigned int timeout, void *arg)
 Progress callback, arg can be used to pass extra parameters required by underlying API. More...
 
typedef int(* hg_request_trigger_func_t )(unsigned int timeout, unsigned int *flag, void *arg)
 Trigger callback, arg can be used to pass extra parameters required by underlying API. More...
 

Functions

HG_UTIL_EXPORT hg_request_class_thg_request_init (hg_request_progress_func_t progress, hg_request_trigger_func_t trigger, void *arg)
 Initialize the request class with the specific progress/trigger functions that will be called on hg_request_wait(). More...
 
HG_UTIL_EXPORT int hg_request_finalize (hg_request_class_t *request_class)
 Finalize the request class. More...
 
HG_UTIL_EXPORT
hg_request_object_t
hg_request_create (hg_request_class_t *request_class)
 Create a new request from a specified request class. More...
 
HG_UTIL_EXPORT int hg_request_destroy (hg_request_object_t *request)
 Destroy the request, freeing the resources. More...
 
HG_UTIL_EXPORT int hg_request_complete (hg_request_object_t *request)
 Mark the request as completed. More...
 
HG_UTIL_EXPORT int hg_request_wait (hg_request_object_t *request, unsigned int timeout, unsigned int *flag)
 Wait timeout ms for the specified request to complete. More...
 
HG_UTIL_EXPORT int hg_request_waitall (int count, hg_request_object_t *request[], unsigned int timeout, unsigned int *flag)
 Wait timeout ms for all the specified request to complete. More...
 
HG_UTIL_EXPORT int hg_request_set_data (hg_request_object_t *request, void *data)
 Attach user data to a specified request. More...
 
HG_UTIL_EXPORT void * hg_request_get_data (hg_request_object_t *request)
 Get user data from a specified request. More...
 

Typedef Documentation

typedef struct hg_request_class hg_request_class_t

Purpose: define a request emulation library on top of the callback model that uses progress/trigger functions.

Definition at line 21 of file mercury_request.h.

typedef struct hg_request_object hg_request_object_t

Definition at line 22 of file mercury_request.h.

typedef int(* hg_request_progress_func_t)(unsigned int timeout, void *arg)

Progress callback, arg can be used to pass extra parameters required by underlying API.

Parameters
timeout[IN] timeout (in milliseconds)
arg[IN] pointer to data passed to callback
Returns
HG_UTIL_SUCCESS if any completion has occurred / error code otherwise

Definition at line 33 of file mercury_request.h.

typedef int(* hg_request_trigger_func_t)(unsigned int timeout, unsigned int *flag, void *arg)

Trigger callback, arg can be used to pass extra parameters required by underlying API.

Parameters
timeout[IN] timeout (in milliseconds)
flag[OUT] 1 if callback has been triggered, 0 otherwise
arg[IN] pointer to data passed to callback
Returns
HG_UTIL_SUCCESS or corresponding error code

Definition at line 45 of file mercury_request.h.

Function Documentation

HG_UTIL_EXPORT hg_request_class_t* hg_request_init ( hg_request_progress_func_t  progress,
hg_request_trigger_func_t  trigger,
void *  arg 
)

Initialize the request class with the specific progress/trigger functions that will be called on hg_request_wait().

arg can be used to pass extra parameters required by underlying API.

Parameters
progress[IN] progress function
trigger[IN] trigger function
arg[IN] pointer to data passed to callback
Returns
Pointer to request class or NULL in case of failure
HG_UTIL_EXPORT int hg_request_finalize ( hg_request_class_t request_class)

Finalize the request class.

Parameters
request_class[IN] pointer to request class
HG_UTIL_EXPORT hg_request_object_t* hg_request_create ( hg_request_class_t request_class)

Create a new request from a specified request class.

The progress function explicitly makes progress and may insert the completed operation into a completion queue. The operation gets triggered after a call to the trigger function.

Parameters
request_class[IN] pointer to request class
Returns
Pointer to request or NULL in case of failure
HG_UTIL_EXPORT int hg_request_destroy ( hg_request_object_t request)

Destroy the request, freeing the resources.

Parameters
request[IN/OUT] pointer to request
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_request_complete ( hg_request_object_t request)

Mark the request as completed.

(most likely called by a callback triggered after a call to trigger)

Parameters
request[IN/OUT] pointer to request
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_request_wait ( hg_request_object_t request,
unsigned int  timeout,
unsigned int *  flag 
)

Wait timeout ms for the specified request to complete.

Parameters
request[IN/OUT] pointer to request
timeout[IN] timeout (in milliseconds)
flag[OUT] 1 if request has completed, 0 otherwise
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_request_waitall ( int  count,
hg_request_object_t request[],
unsigned int  timeout,
unsigned int *  flag 
)

Wait timeout ms for all the specified request to complete.

Parameters
count[IN] number of requests
request[IN/OUT] arrays of requests
timeout[IN] timeout (in milliseconds)
flag[OUT] 1 if all requests have completed, 0 otherwise
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_request_set_data ( hg_request_object_t request,
void *  data 
)

Attach user data to a specified request.

Parameters
request[IN/OUT] pointer to request
data[IN] pointer to data
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT void* hg_request_get_data ( hg_request_object_t request)

Get user data from a specified request.

Parameters
request[IN/OUT] pointer to request
Returns
Pointer to data or NULL if nothing was attached by user