本文整理汇总了C++中PMIX_NEW函数的典型用法代码示例。如果您正苦于以下问题:C++ PMIX_NEW函数的具体用法?C++ PMIX_NEW怎么用?C++ PMIX_NEW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMIX_NEW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: publish_fn
int publish_fn(const pmix_proc_t *proc,
const pmix_info_t info[], size_t ninfo,
pmix_op_cbfunc_t cbfunc, void *cbdata)
{
size_t i;
int found;
pmix_test_info_t *new_info, *old_info;
if (NULL == pmix_test_published_list) {
pmix_test_published_list = PMIX_NEW(pmix_list_t);
}
for (i = 0; i < ninfo; i++) {
found = 0;
PMIX_LIST_FOREACH(old_info, pmix_test_published_list, pmix_test_info_t) {
if (!strcmp(old_info->data.key, info[i].key)) {
found = 1;
break;
}
}
if (!found) {
new_info = PMIX_NEW(pmix_test_info_t);
strncpy(new_info->data.key, info[i].key, strlen(info[i].key)+1);
pmix_value_xfer(&new_info->data.value, (pmix_value_t*)&info[i].value);
new_info->namespace_published = strdup(proc->nspace);
new_info->rank_published = proc->rank;
pmix_list_append(pmix_test_published_list, &new_info->super);
}
}
if (NULL != cbfunc) {
cbfunc(PMIX_SUCCESS, cbdata);
}
return PMIX_SUCCESS;
}
示例2: PMIx_Disconnect_nb
int PMIx_Disconnect_nb(const pmix_proc_t procs[], size_t nprocs,
pmix_op_cbfunc_t cbfunc, void *cbdata)
{
pmix_buffer_t *msg;
pmix_cmd_t cmd = PMIX_DISCONNECTNB_CMD;
int rc;
pmix_cb_t *cb;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: disconnect called");
if (pmix_client_globals.init_cntr <= 0) {
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
return PMIX_ERR_UNREACH;
}
/* check for bozo input */
if (NULL == procs || 0 >= nprocs) {
return PMIX_ERR_BAD_PARAM;
}
msg = PMIX_NEW(pmix_buffer_t);
/* pack the cmd */
if (PMIX_SUCCESS != (rc = pmix_bfrop.pack(msg, &cmd, 1, PMIX_CMD))) {
PMIX_ERROR_LOG(rc);
return rc;
}
/* pack the number of procs */
if (PMIX_SUCCESS != (rc = pmix_bfrop.pack(msg, &nprocs, 1, PMIX_SIZE))) {
PMIX_ERROR_LOG(rc);
return rc;
}
if (PMIX_SUCCESS != (rc = pmix_bfrop.pack(msg, procs, nprocs, PMIX_PROC))) {
PMIX_ERROR_LOG(rc);
return rc;
}
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->op_cbfunc = cbfunc;
cb->cbdata = cbdata;
/* push the message into our event base to send to the server */
PMIX_ACTIVATE_SEND_RECV(&pmix_client_globals.myserver, msg, wait_cbfunc, cb);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: disconnect completed");
return PMIX_SUCCESS;
}
示例3: PMIx_Fence_nb
PMIX_EXPORT pmix_status_t PMIx_Fence_nb(const pmix_proc_t procs[], size_t nprocs,
const pmix_info_t info[], size_t ninfo,
pmix_op_cbfunc_t cbfunc, void *cbdata)
{
pmix_buffer_t *msg;
pmix_cmd_t cmd = PMIX_FENCENB_CMD;
pmix_status_t rc;
pmix_cb_t *cb;
pmix_proc_t rg, *rgs;
size_t nrg;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: fence_nb called");
if (pmix_globals.init_cntr <= 0) {
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
return PMIX_ERR_UNREACH;
}
/* check for bozo input */
if (NULL == procs && 0 != nprocs) {
return PMIX_ERR_BAD_PARAM;
}
/* if we are given a NULL proc, then the caller is referencing
* all procs within our own nspace */
if (NULL == procs) {
(void)strncpy(rg.nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN);
rg.rank = PMIX_RANK_WILDCARD;
rgs = &rg;
nrg = 1;
} else {
rgs = (pmix_proc_t*)procs;
nrg = nprocs;
}
msg = PMIX_NEW(pmix_buffer_t);
if (PMIX_SUCCESS != (rc = pack_fence(msg, cmd, rgs, nrg, info, ninfo))) {
PMIX_RELEASE(msg);
return rc;
}
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->op_cbfunc = cbfunc;
cb->cbdata = cbdata;
/* push the message into our event base to send to the server */
PMIX_ACTIVATE_SEND_RECV(&pmix_client_globals.myserver, msg, wait_cbfunc, cb);
return PMIX_SUCCESS;
}
示例4: PMIx_Lookup
PMIX_EXPORT pmix_status_t PMIx_Lookup(pmix_pdata_t pdata[], size_t ndata,
const pmix_info_t info[], size_t ninfo)
{
pmix_status_t rc;
pmix_cb_t *cb;
char **keys = NULL;
size_t i;
PMIX_ACQUIRE_THREAD(&pmix_global_lock);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: lookup called");
if (pmix_globals.init_cntr <= 0) {
PMIX_RELEASE_THREAD(&pmix_global_lock);
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
PMIX_RELEASE_THREAD(&pmix_global_lock);
return PMIX_ERR_UNREACH;
}
PMIX_RELEASE_THREAD(&pmix_global_lock);
/* bozo protection */
if (NULL == pdata) {
return PMIX_ERR_BAD_PARAM;
}
/* transfer the pdata keys to the keys argv array */
for (i=0; i < ndata; i++) {
if ('\0' != pdata[i].key[0]) {
pmix_argv_append_nosize(&keys, pdata[i].key);
}
}
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->cbdata = (void*)pdata;
cb->nvals = ndata;
if (PMIX_SUCCESS != (rc = PMIx_Lookup_nb(keys, info, ninfo,
lookup_cbfunc, cb))) {
PMIX_RELEASE(cb);
pmix_argv_free(keys);
return rc;
}
/* wait for the server to ack our request */
PMIX_WAIT_THREAD(&cb->lock);
/* the data has been stored in the info array by lookup_cbfunc, so
* nothing more for us to do */
rc = cb->status;
PMIX_RELEASE(cb);
return rc;
}
示例5: PMIx_Disconnect
int PMIx_Disconnect(const pmix_proc_t procs[], size_t nprocs)
{
int rc;
pmix_cb_t *cb;
if (pmix_client_globals.init_cntr <= 0) {
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
return PMIX_ERR_UNREACH;
}
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->active = true;
if (PMIX_SUCCESS != (rc = PMIx_Disconnect_nb(procs, nprocs, op_cbfunc, cb))) {
PMIX_RELEASE(cb);
return rc;
}
/* wait for the connect to complete */
PMIX_WAIT_FOR_COMPLETION(cb->active);
rc = cb->status;
PMIX_RELEASE(cb);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: disconnect completed");
return rc;
}
示例6: pmix_add_errhandler
pmix_status_t pmix_add_errhandler(pmix_notification_fn_t err,
pmix_info_t *info, int ninfo,
int *index)
{
int i;
pmix_status_t rc = PMIX_SUCCESS;
pmix_error_reg_info_t *errreg;
errreg = PMIX_NEW(pmix_error_reg_info_t);
errreg->errhandler = err;
errreg->ninfo = ninfo;
if (NULL != info && 0 < ninfo) {
PMIX_INFO_CREATE(errreg->info, ninfo);
for (i=0; i < ninfo; i++) {
(void)strncpy(errreg->info[i].key, info[i].key, PMIX_MAX_KEYLEN);
pmix_value_xfer(&errreg->info[i].value, &info[i].value);
}
}
*index = pmix_pointer_array_add(&pmix_globals.errregs, errreg);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix_add_errhandler index =%d", *index);
if (*index < 0) {
PMIX_RELEASE(errreg);
rc = PMIX_ERROR;
}
return rc;
}
示例7: PMIx_Unpublish
PMIX_EXPORT pmix_status_t PMIx_Unpublish(char **keys,
const pmix_info_t info[], size_t ninfo)
{
pmix_status_t rc;
pmix_cb_t *cb;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: unpublish called");
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->active = true;
/* push the message into our event base to send to the server */
if (PMIX_SUCCESS != (rc = PMIx_Unpublish_nb(keys, info, ninfo, op_cbfunc, cb))) {
PMIX_RELEASE(cb);
return rc;
}
/* wait for the server to ack our request */
PMIX_WAIT_FOR_COMPLETION(cb->active);
rc = cb->status;
PMIX_RELEASE(cb);
return rc;
}
示例8: save_value
static void save_value(const char *name, const char *value)
{
pmix_mca_base_var_file_value_t *fv;
bool found = false;
/* First traverse through the list and ensure that we don't
already have a param of this name. If we do, just replace the
value. */
PMIX_LIST_FOREACH(fv, _param_list, pmix_mca_base_var_file_value_t) {
if (0 == strcmp(name, fv->mbvfv_var)) {
if (NULL != fv->mbvfv_value) {
free (fv->mbvfv_value);
}
found = true;
break;
}
}
if (!found) {
/* We didn't already have the param, so append it to the list */
fv = PMIX_NEW(pmix_mca_base_var_file_value_t);
if (NULL == fv) {
return;
}
fv->mbvfv_var = strdup(name);
pmix_list_append(_param_list, &fv->super);
}
fv->mbvfv_value = value ? strdup(value) : NULL;
fv->mbvfv_file = file_being_read;
fv->mbvfv_lineno = pmix_util_keyval_parse_lineno;
}
示例9: PMIx_Publish
PMIX_EXPORT pmix_status_t PMIx_Publish(const pmix_info_t info[],
size_t ninfo)
{
pmix_status_t rc;
pmix_cb_t *cb;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: publish called");
if (pmix_globals.init_cntr <= 0) {
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
return PMIX_ERR_UNREACH;
}
/* create a callback object to let us know when it is done */
cb = PMIX_NEW(pmix_cb_t);
cb->active = true;
if (PMIX_SUCCESS != (rc = PMIx_Publish_nb(info, ninfo, op_cbfunc, cb))) {
PMIX_ERROR_LOG(rc);
PMIX_RELEASE(cb);
return rc;
}
/* wait for the server to ack our request */
PMIX_WAIT_FOR_COMPLETION(cb->active);
rc = (pmix_status_t)cb->status;
PMIX_RELEASE(cb);
return rc;
}
示例10: pmix_bfrop_copy_buf
int pmix_bfrop_copy_buf(pmix_buffer_t **dest, pmix_buffer_t *src,
pmix_data_type_t type)
{
*dest = PMIX_NEW(pmix_buffer_t);
pmix_bfrop.copy_payload(*dest, src);
return PMIX_SUCCESS;
}
示例11: setup_app
static pmix_status_t setup_app(char *nspace, pmix_list_t *ilist)
{
uint64_t unique_key[2];
char *string_key, *cs_env;
int fd_rand;
size_t bytes_read;
pmix_kval_t *kv;
/* put the number here - or else create an appropriate string. this just needs to
* eventually be a string variable
*/
if(-1 == (fd_rand = open("/dev/urandom", O_RDONLY))) {
transports_use_rand(unique_key);
} else {
bytes_read = read(fd_rand, (char *) unique_key, 16);
if(bytes_read != 16) {
transports_use_rand(unique_key);
}
close(fd_rand);
}
if (NULL == (string_key = transports_print(unique_key))) {
PMIX_ERROR_LOG(PMIX_ERR_OUT_OF_RESOURCE);
return PMIX_ERR_OUT_OF_RESOURCE;
}
if (PMIX_SUCCESS != pmix_mca_base_var_env_name("pmix_precondition_transports", &cs_env)) {
PMIX_ERROR_LOG(PMIX_ERR_OUT_OF_RESOURCE);
free(string_key);
return PMIX_ERR_OUT_OF_RESOURCE;
}
kv = PMIX_NEW(pmix_kval_t);
if (NULL == kv) {
free(string_key);
free(cs_env);
return PMIX_ERR_OUT_OF_RESOURCE;
}
kv->key = strdup(PMIX_SET_ENVAR);
kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t));
if (NULL == kv->value) {
free(string_key);
free(cs_env);
PMIX_RELEASE(kv);
return PMIX_ERR_OUT_OF_RESOURCE;
}
kv->value->type = PMIX_STRING;
if (0 > asprintf(&kv->value->data.string, "%s=%s", cs_env, string_key)) {
free(string_key);
free(cs_env);
PMIX_RELEASE(kv);
return PMIX_ERR_OUT_OF_RESOURCE;
}
pmix_list_append(ilist, &kv->super);
free(cs_env);
free(string_key);
return PMIX_SUCCESS;
}
示例12: query_cbfunc
static void query_cbfunc(struct pmix_peer_t *peer,
pmix_ptl_hdr_t *hdr,
pmix_buffer_t *buf, void *cbdata)
{
pmix_query_caddy_t *cd = (pmix_query_caddy_t*)cbdata;
pmix_status_t rc;
pmix_shift_caddy_t *results;
int cnt;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix:query cback from server");
results = PMIX_NEW(pmix_shift_caddy_t);
/* unpack the status */
cnt = 1;
PMIX_BFROPS_UNPACK(rc, peer, buf, &results->status, &cnt, PMIX_STATUS);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
results->status = rc;
goto complete;
}
if (PMIX_SUCCESS != results->status) {
goto complete;
}
/* unpack any returned data */
cnt = 1;
PMIX_BFROPS_UNPACK(rc, peer, buf, &results->ninfo, &cnt, PMIX_SIZE);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
results->status = rc;
goto complete;
}
if (0 < results->ninfo) {
PMIX_INFO_CREATE(results->info, results->ninfo);
cnt = results->ninfo;
PMIX_BFROPS_UNPACK(rc, peer, buf, results->info, &cnt, PMIX_INFO);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
results->status = rc;
goto complete;
}
}
complete:
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix:query cback from server releasing");
/* release the caller */
if (NULL != cd->cbfunc) {
cd->cbfunc(results->status, results->info, results->ninfo, cd->cbdata, relcbfunc, results);
}
PMIX_RELEASE(cd);
}
示例13: PMIx_Lookup
int PMIx_Lookup(pmix_data_range_t scope,
const pmix_info_t info[], size_t ninfo,
pmix_pdata_t pdata[], size_t ndata)
{
int rc;
pmix_cb_t *cb;
char **keys = NULL;
size_t i;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: lookup called");
/* bozo protection */
if (NULL == pdata) {
return PMIX_ERR_BAD_PARAM;
}
/* transfer the pdata keys to the keys argv array */
for (i=0; i < ndata; i++) {
if ('\0' != pdata[i].key[0]) {
pmix_argv_append_nosize(&keys, pdata[i].key);
}
}
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
cb->cbdata = (void*)pdata;
cb->nvals = ndata;
cb->active = true;
if (PMIX_SUCCESS != (rc = PMIx_Lookup_nb(scope, keys,
info, ninfo,
lookup_cbfunc, cb))) {
PMIX_RELEASE(cb);
pmix_argv_free(keys);
return rc;
}
/* wait for the server to ack our request */
PMIX_WAIT_FOR_COMPLETION(cb->active);
/* the data has been stored in the info array by lookup_cbfunc, so
* nothing more for us to do */
rc = cb->status;
PMIX_RELEASE(cb);
return rc;
}
示例14: pmix_usock_send
static void pmix_usock_send(int sd, short args, void *cbdata)
{
pmix_ptl_queue_t *queue = (pmix_ptl_queue_t*)cbdata;
pmix_ptl_send_t *snd;
/* acquire the object */
PMIX_ACQUIRE_OBJECT(queue);
if (NULL == queue->peer || queue->peer->sd < 0 ||
NULL == queue->peer->info || NULL == queue->peer->nptr) {
/* this peer has lost connection */
PMIX_RELEASE(queue);
/* ensure we post the object before another thread
* picks it back up */
PMIX_POST_OBJECT(queue);
return;
}
pmix_output_verbose(2, pmix_ptl_base_framework.framework_output,
"[%s:%d] send to %s:%u on tag %d",
__FILE__, __LINE__,
(queue->peer)->info->pname.nspace,
(queue->peer)->info->pname.rank, (queue->tag));
snd = PMIX_NEW(pmix_ptl_send_t);
snd->hdr.pindex = htonl(pmix_globals.pindex);
snd->hdr.tag = htonl(queue->tag);
snd->hdr.nbytes = htonl((queue->buf)->bytes_used);
snd->data = (queue->buf);
/* always start with the header */
snd->sdptr = (char*)&snd->hdr;
snd->sdbytes = sizeof(pmix_ptl_hdr_t);
/* if there is no message on-deck, put this one there */
if (NULL == (queue->peer)->send_msg) {
(queue->peer)->send_msg = snd;
} else {
/* add it to the queue */
pmix_list_append(&(queue->peer)->send_queue, &snd->super);
}
/* ensure the send event is active */
if (!(queue->peer)->send_ev_active) {
(queue->peer)->send_ev_active = true;
PMIX_POST_OBJECT(queue->peer);
pmix_event_add(&(queue->peer)->send_event, 0);
}
PMIX_RELEASE(queue);
PMIX_POST_OBJECT(snd);
}
示例15: PMIx_Fence
PMIX_EXPORT pmix_status_t PMIx_Fence(const pmix_proc_t procs[], size_t nprocs,
const pmix_info_t info[], size_t ninfo)
{
pmix_cb_t *cb;
pmix_status_t rc;
PMIX_ACQUIRE_THREAD(&pmix_global_lock);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: executing fence");
if (pmix_globals.init_cntr <= 0) {
PMIX_RELEASE_THREAD(&pmix_global_lock);
return PMIX_ERR_INIT;
}
/* if we aren't connected, don't attempt to send */
if (!pmix_globals.connected) {
PMIX_RELEASE_THREAD(&pmix_global_lock);
return PMIX_ERR_UNREACH;
}
PMIX_RELEASE_THREAD(&pmix_global_lock);
/* create a callback object as we need to pass it to the
* recv routine so we know which callback to use when
* the return message is recvd */
cb = PMIX_NEW(pmix_cb_t);
/* push the message into our event base to send to the server */
if (PMIX_SUCCESS != (rc = PMIx_Fence_nb(procs, nprocs, info, ninfo,
op_cbfunc, cb))) {
PMIX_ERROR_LOG(rc);
PMIX_RELEASE(cb);
return rc;
}
/* wait for the fence to complete */
PMIX_WAIT_THREAD(&cb->lock);
rc = cb->status;
PMIX_RELEASE(cb);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: fence released");
return rc;
}