Skip to content

Commit

Permalink
libflux/rpc: add aux_get/set, type_get/set
Browse files Browse the repository at this point in the history
This will assist with wrapping/extending flux_rpc_t for specific RPC classes.
  • Loading branch information
garlick committed Jul 23, 2015
1 parent 01a31b2 commit 53208a6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/common/libflux/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct flux_rpc_struct {
flux_msg_t *rx_msg_consumed;
int rx_count;
bool oneway;
void *aux;
flux_free_f aux_destroy;
const char *type;
};

void flux_rpc_destroy (flux_rpc_t *rpc)
Expand All @@ -71,6 +74,8 @@ void flux_rpc_destroy (flux_rpc_t *rpc)
flux_msg_destroy (rpc->rx_msg_consumed);
if (rpc->nodemap)
free (rpc->nodemap);
if (rpc->aux && rpc->aux_destroy)
rpc->aux_destroy (rpc->aux);
free (rpc);
}
}
Expand Down Expand Up @@ -295,6 +300,29 @@ flux_rpc_t *flux_rpc_multi (flux_t h, const char *topic, const char *json_str,
return NULL;
}

const char *flux_rpc_type_get (flux_rpc_t *rpc)
{
return rpc->type;
}

void flux_rpc_type_set (flux_rpc_t *rpc, const char *type)
{
rpc->type = type;
}

void *flux_rpc_aux_get (flux_rpc_t *rpc)
{
return rpc->aux;
}

void flux_rpc_aux_set (flux_rpc_t *rpc, void *aux, flux_free_f destroy)
{
if (rpc->aux && rpc->aux_destroy)
rpc->aux_destroy (rpc->aux);
rpc->aux = aux;
rpc->aux_destroy = destroy;
}

/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
7 changes: 7 additions & 0 deletions src/common/libflux/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ flux_rpc_t *flux_rpc_multi (flux_t h, const char *topic, const char *json_str,
*/
bool flux_rpc_completed (flux_rpc_t *rpc);

/* Helper functions for extending flux_rpc_t.
*/
const char *flux_rpc_type_get (flux_rpc_t *rpc);
void flux_rpc_type_set (flux_rpc_t *rpc, const char *type);
void *flux_rpc_aux_get (flux_rpc_t *rpc);
void flux_rpc_aux_set (flux_rpc_t *rpc, void *aux, flux_free_f destroy);

#endif /* !_FLUX_CORE_RPC_H */

/*
Expand Down

0 comments on commit 53208a6

Please sign in to comment.