Commit 8ca94fd9 authored by Philip Carns's avatar Philip Carns

clean up margo mplex registration

parent 0b7c3064
...@@ -142,6 +142,8 @@ int main(int argc, char **argv) ...@@ -142,6 +142,8 @@ int main(int argc, char **argv)
*/ */
margo_wait_for_finalize(mid); margo_wait_for_finalize(mid);
svc1_deregister(mid, margo_get_handler_pool(mid), 1);
ABT_finalize(); ABT_finalize();
HG_Context_destroy(hg_context); HG_Context_destroy(hg_context);
......
...@@ -22,6 +22,7 @@ static void svc1_do_thing_ult(hg_handle_t handle) ...@@ -22,6 +22,7 @@ static void svc1_do_thing_ult(hg_handle_t handle)
ret = HG_Get_input(handle, &in); ret = HG_Get_input(handle, &in);
assert(ret == HG_SUCCESS); assert(ret == HG_SUCCESS);
/* TODO: print handler name, mplex_id, and pool */
printf("Got RPC request with input_val: %d\n", in.input_val); printf("Got RPC request with input_val: %d\n", in.input_val);
out.ret = 0; out.ret = 0;
...@@ -73,6 +74,7 @@ static void svc1_do_other_thing_ult(hg_handle_t handle) ...@@ -73,6 +74,7 @@ static void svc1_do_other_thing_ult(hg_handle_t handle)
ret = HG_Get_input(handle, &in); ret = HG_Get_input(handle, &in);
assert(ret == HG_SUCCESS); assert(ret == HG_SUCCESS);
/* TODO: print handler name, mplex_id, and pool */
printf("Got RPC request with input_val: %d\n", in.input_val); printf("Got RPC request with input_val: %d\n", in.input_val);
out.ret = 0; out.ret = 0;
...@@ -111,28 +113,8 @@ DEFINE_MARGO_RPC_HANDLER(svc1_do_other_thing_ult) ...@@ -111,28 +113,8 @@ DEFINE_MARGO_RPC_HANDLER(svc1_do_other_thing_ult)
int svc1_register(margo_instance_id mid, ABT_pool pool, uint32_t mplex_id) int svc1_register(margo_instance_id mid, ABT_pool pool, uint32_t mplex_id)
{ {
hg_return_t hret; MARGO_REGISTER(mid, "svc1_do_thing", svc1_do_thing_in_t, svc1_do_thing_out_t, svc1_do_thing_ult_handler, mplex_id, pool);
hg_id_t id; MARGO_REGISTER(mid, "svc1_do_other_thing", svc1_do_other_thing_in_t, svc1_do_other_thing_out_t, svc1_do_other_thing_ult_handler, mplex_id, pool);
hg_bool_t flag;
int ret;
/* TODO: the following, for each function */
/* TODO: this should be a macro really */
hret = HG_Registered_name(margo_get_class(mid), "svc1_do_thing", &id, &flag);
if(hret != HG_SUCCESS)
{
return(-1);
}
if(!flag)
{
id = MERCURY_REGISTER(margo_get_class(mid), "svc1_do_thing", svc1_do_thing_in_t, svc1_do_thing_out_t, svc1_do_thing_ult_handler);
}
ret = margo_register_mplex(mid, id, mplex_id, pool);
if(ret < 0)
{
return(ret);
}
return(0); return(0);
} }
......
...@@ -208,6 +208,19 @@ int margo_register_mplex(margo_instance_id mid, hg_id_t id, uint32_t mplex_id, A ...@@ -208,6 +208,19 @@ int margo_register_mplex(margo_instance_id mid, hg_id_t id, uint32_t mplex_id, A
*/ */
int margo_lookup_mplex(margo_instance_id mid, hg_id_t id, uint32_t mplex_id, ABT_pool *pool); int margo_lookup_mplex(margo_instance_id mid, hg_id_t id, uint32_t mplex_id, ABT_pool *pool);
#define MARGO_REGISTER(__mid, __func_name, __in_t, __out_t, __handler, __mplex_id, __pool) do { \
hg_return_t __hret; \
hg_id_t __id; \
hg_bool_t __flag; \
int __ret; \
__hret = HG_Registered_name(margo_get_class(__mid), __func_name, &__id, &__flag); \
assert(__hret == HG_SUCCESS); \
if(!__flag) \
__id = MERCURY_REGISTER(margo_get_class(__mid), __func_name, __in_t, __out_t, __handler); \
__ret = margo_register_mplex(__mid, __id, __mplex_id, __pool); \
assert(__ret = 0); \
} while(0)
/** /**
* macro that defines a function to glue an RPC handler to a ult handler * macro that defines a function to glue an RPC handler to a ult handler
* @param [in] __name name of handler function * @param [in] __name name of handler function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment