当前位置: 首页>>代码示例>>C++>>正文


C++ zhash_insert函数代码示例

本文整理汇总了C++中zhash_insert函数的典型用法代码示例。如果您正苦于以下问题:C++ zhash_insert函数的具体用法?C++ zhash_insert怎么用?C++ zhash_insert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zhash_insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: zhash_dup

zhash_t *
zhash_dup (zhash_t *self)
{
    if (!self)
        return NULL;

    zhash_t *copy = zhash_new ();
    if (copy) {
        copy->destructor = self->destructor;
        copy->duplicator = self->duplicator;
        uint index;
        size_t limit = primes [self->prime_index];
        for (index = 0; index < limit; index++) {
            item_t *item = self->items [index];
            while (item) {
                if (zhash_insert (copy, item->key, item->value)) {
                    zhash_destroy (&copy);
                    break;
                }
                item = item->next;
            }
        }
    }
    return copy;
}
开发者ID:PSG-Luna,项目名称:czmq,代码行数:25,代码来源:zhash.c

示例2: zcertstore_insert

void
zcertstore_insert (zcertstore_t *self, zcert_t **cert_p)
{
    zlist_append (self->cert_list, *cert_p);
    zhash_insert (self->cert_hash, zcert_public_txt (*cert_p), *cert_p);
    *cert_p = NULL;             //  We own this now
}
开发者ID:Prarrot,项目名称:czmq,代码行数:7,代码来源:zcertstore.c

示例3: agent_control_message

void 
agent_control_message (agent_t *self)
{
    zmsg_t *msg = zmsg_recv (self->control);
    char *command = zmsg_pop (msg);

    if (strcmp (command, "CONNECT") == 0) {
        char *endpoint = zmsg_pop (msg);
        printf ("I: connecting to %s...\n", endpoint);
        int rc = zmq_connect (self->router, endpoint);
        assert (rc == 0);
        server_t *server = server_new (endpoint);
        zhash_insert (self->servers, endpoint, server);
        zhash_freefn (self->servers, endpoint, s_server_free);
        zlist_append (self->actives, server);
        server->ping_at = s_clock () + PING_INTERVAL;
        server->expires = s_clock () + SERVER_TTL;
        free (endpoint);
    }
    else
    if (strcmp (command, "REQUEST") == 0) {
        assert (!self->request);    //  Strict request-reply cycle
        //  Prefix request with sequence number and empty envelope
        char sequence_text [10];
        sprintf (sequence_text, "%u", ++self->sequence);
        zmsg_push (msg, sequence_text);
        //  Take ownership of request message
        self->request = msg;
        msg = NULL;
        //  Request expires after global timeout
        self->expires = s_clock () + GLOBAL_TIMEOUT;
    }
    free (command);
    zmsg_destroy (&msg);
}
开发者ID:tzuryby,项目名称:zguide,代码行数:35,代码来源:flcliapi.c

示例4: s_zdir_watch_subscribe

static void
s_zdir_watch_subscribe (zdir_watch_t *watch, const char *path)
{
    if (watch->verbose)
        zsys_info ("zdir_watch: Subscribing to directory path: %s", path);

    zdir_watch_sub_t *sub = (zdir_watch_sub_t *) zmalloc (sizeof (zdir_watch_sub_t));
    sub->dir = zdir_new (path, NULL);
    if (!sub->dir) {
        if (watch->verbose)
            zsys_error ("zdir_watch: Unable to create zdir for path: %s", path);
        zsock_signal (watch->pipe, 1);
        return;
    }

    int rc = zhash_insert (watch->subs, path, sub);
    if (rc) {
        if (watch->verbose)
            zsys_error ("zdir_watch: Unable to insert path '%s' into subscription list", path);
        zsock_signal (watch->pipe, 1);
        return;
    }

    void *item = zhash_freefn (watch->subs, path, s_sub_free);
    if (item != sub) {
        if (watch->verbose)
            zsys_error ("zdir_watch: Unable to set free fn for path %s", path);
        zsock_signal (watch->pipe, 1);
        return;
    }

    if (watch->verbose)
        zsys_info ("zdir_watch: Successfully subscribed to %s", path);
    zsock_signal (watch->pipe, 0);
}
开发者ID:diorcety,项目名称:czmq,代码行数:35,代码来源:zdir.c

示例5: fixup_newjob_event

static void fixup_newjob_event (flux_t *h, int64_t nj)
{
    json_object *ss = NULL;
    json_object *jcb = NULL;
    int64_t js = J_NULL;
    char *key = xasprintf ("%"PRId64, nj);
    jscctx_t *ctx = getctx (h);

    /* We fix up ordering problem only when new job
       event hasn't been reported through a kvs watch
     */
    jcb = Jnew ();
    ss = Jnew ();
    Jadd_int64 (jcb, JSC_JOBID, nj);
    Jadd_int64 (ss, JSC_STATE_PAIR_OSTATE , (int64_t) js);
    Jadd_int64 (ss, JSC_STATE_PAIR_NSTATE, (int64_t) js);
    json_object_object_add (jcb, JSC_STATE_PAIR, ss);
    if (zhash_insert (ctx->active_jobs, key, (void *)(intptr_t)js) < 0) {
        flux_log (h, LOG_ERR, "new_job_cb: inserting a job to hash failed");
        goto done;
    }
    if (invoke_cbs (h, nj, jcb, 0) < 0) {
        flux_log (h, LOG_ERR,
                     "makeup_newjob_event: failed to invoke callbacks");
        goto done;
    }
done:
    Jput (jcb);
    free (key);
    return;
}
开发者ID:trws,项目名称:flux-core,代码行数:31,代码来源:jstatctl.c

示例6: zhash_new

static zhash_t *determine_all_min_bandwidth (struct rdl *rdl,
                                             zlist_t *running_jobs)
{
    double root_bw;
    double *curr_value = NULL;
    struct resource *root = NULL;
    job_t *curr_job = NULL;
    char job_id_str[100];
    zhash_t *job_hash = zhash_new ();

    root = rdl_resource_get (rdl, "default");
    root_bw = get_max_bandwidth (root);

    curr_job = zlist_first (running_jobs);
    while (curr_job != NULL) {
        curr_value = (double *)malloc (sizeof (double));
        *curr_value = root_bw;
        sprintf (job_id_str, "%d", curr_job->id);
        zhash_insert (job_hash, job_id_str, curr_value);
        zhash_freefn (job_hash, job_id_str, free);
        curr_job = zlist_next (running_jobs);
    }

    determine_all_min_bandwidth_helper (root, root_bw, job_hash);

    return job_hash;
}
开发者ID:garlick,项目名称:flux-sched,代码行数:27,代码来源:sim_execsrv.c

示例7: _disp_table_insert

static halutils_err_e _disp_table_insert (disp_table_t *self, uint32_t key,
        disp_table_func_fp func_fp)
{
    if (func_fp == NULL) {
        return HALUTILS_ERR_NULL_POINTER;
    }

    DBE_DEBUG (DBG_HAL_UTILS | DBG_LVL_TRACE,
            "[halutils:disp_table] Registering function (%p) opcode (%u) into dispatch table\n",
            func_fp, key);

    func_fp_wrapper_t *func_fp_wrapper = zmalloc (sizeof *func_fp_wrapper);
    ASSERT_ALLOC (func_fp_wrapper, err_func_wrapper_alloc);

    /* Initialize func_p_wrapper struct */
    func_fp_wrapper->func_fp = func_fp;

    char *key_c = halutils_stringify_key (key);
    ASSERT_ALLOC (key_c, err_key_c_alloc);
    int zerr = zhash_insert (self->table_h, key_c, func_fp_wrapper);
    ASSERT_TEST(zerr == 0, "Could not insert item into dispatch table", err_insert_hash);
    /* Setup free function */
    zhash_freefn (self->table_h, key_c, _disp_table_free_item);

    free (key_c);
    return HALUTILS_SUCCESS;

err_insert_hash:
    free (key_c);
err_key_c_alloc:
    free (func_fp_wrapper);
err_func_wrapper_alloc:
    return HALUTILS_ERR_ALLOC;
}
开发者ID:julianofjm,项目名称:bpm-software,代码行数:34,代码来源:dispatch_table.c

示例8: sub_patch_add

static void
sub_patch_add (sub_t *self, fmq_patch_t *patch)
{
    //  Skip file creation if client already has identical file
    fmq_patch_digest_set (patch);
    if (fmq_patch_op (patch) == patch_create) {
        char *digest = zhash_lookup (self->cache, fmq_patch_virtual (patch));
        if (digest && strcasecmp (digest, fmq_patch_digest (patch)) == 0)
            return;             //  Just skip patch for this client
    }
    //  Remove any previous patches for the same file
    fmq_patch_t *existing = (fmq_patch_t *) zlist_first (self->client->patches);
    while (existing) {
        if (streq (fmq_patch_virtual (patch), fmq_patch_virtual (existing))) {
            zlist_remove (self->client->patches, existing);
            fmq_patch_destroy (&existing);
            break;
        }
        existing = (fmq_patch_t *) zlist_next (self->client->patches);
    }
    if (fmq_patch_op (patch) == patch_create)
        zhash_insert (self->cache,
            fmq_patch_digest (patch), fmq_patch_virtual (patch));
    //  Track that we've queued patch for client, so we don't do it twice
    zlist_append (self->client->patches, fmq_patch_dup (patch));
}
开发者ID:JuanCerezuela,项目名称:filemq,代码行数:26,代码来源:fmq_server.c

示例9: s_service_require

static service_t *
s_service_require (broker_t *self, zframe_t *service_frame)
{
    assert (service_frame);
    char *name = zframe_strdup (service_frame);

    service_t *service =
        (service_t *) zhash_lookup (self->services, name);
    if (service == NULL) {
        service = (service_t *) zmalloc (sizeof (service_t));
        service->broker = self;
        service->name = name;
        service->requests = zlist_new ();
        service->waiting = zlist_new ();
        service->blacklist = zlist_new ();
        zhash_insert (self->services, name, service);
        zhash_freefn (self->services, name, s_service_destroy);
        if (self->verbose)
            zclock_log ("I: added service: %s", name);
    }
    else
        free (name);

    return service;
}
开发者ID:mocosun,项目名称:majordomo,代码行数:25,代码来源:mdp_broker.c

示例10: zyre_group_join

void
zyre_group_join (zyre_group_t *self, zyre_peer_t *peer)
{
    assert (self);
    assert (peer);
    zhash_insert (self->peers, zyre_peer_identity (peer), peer);
    zyre_peer_set_status (peer, zyre_peer_status (peer) + 1);
}
开发者ID:Muraad,项目名称:zyre,代码行数:8,代码来源:zyre_group.c

示例11: barrier_add_client

static int barrier_add_client (barrier_t *b, char *sender, zmsg_t **zmsg)
{
    if (zhash_insert (b->clients, sender, *zmsg) < 0)
        return -1;
    zhash_freefn (b->clients, sender, (zhash_free_fn *)free_zmsg);
    *zmsg = NULL; /* list owns it now */
    return 0;
}
开发者ID:trws,项目名称:flux-barrier,代码行数:8,代码来源:xbarrier.c

示例12: barrier_add_client

static int barrier_add_client (barrier_t *b, char *sender, const flux_msg_t *msg)
{
    flux_msg_t *cpy = flux_msg_copy (msg, true);
    if (!cpy || zhash_insert (b->clients, sender, cpy) < 0)
        return -1;
    zhash_freefn (b->clients, sender, (zhash_free_fn *)flux_msg_destroy);
    return 0;
}
开发者ID:SteVwonder,项目名称:flux-core,代码行数:8,代码来源:barrier.c

示例13: zcert_set_meta

void
zcert_set_meta (zcert_t *self, const char *name, const char *format, ...)
{
    va_list argptr;
    va_start (argptr, format);
    char *value = zsys_vprintf (format, argptr);
    va_end (argptr);
    zhash_insert (self->metadata, name, value);
    zstr_free (&value);
}
开发者ID:drmplanet,项目名称:kdlenv,代码行数:10,代码来源:zcert.c

示例14: zargs_new

zargs_t *
zargs_new (int argc, char **argv)
{
    assert (argc > 0);
    assert (argv);
    zargs_t *self = (zargs_t *) zmalloc (sizeof (zargs_t));
    assert (self);
    //  Initialize class properties here
    self->progname = argv [0];
    assert (self->progname);
    self->arguments = zlist_new ();
    assert (self->arguments);
    self->parameters = zhash_new ();
    assert (self->parameters);

    if (argc == 1)
        return self;

    int idx = 1;
    bool params_only = false;
    while (argv [idx]) {
        if (params_only || argv [idx][0] != '-')
            zlist_append (self->arguments, argv [idx]);
        else {
	    if (streq (argv [idx], "--")) {
	        params_only = true;
            idx ++;
            continue;
	    }
	    else
            if (argv [idx+1] && argv [idx+1][0] != '-') {
                zhash_insert (self->parameters, argv [idx], argv [idx+1]);
                idx ++;
            }
            else {
                zhash_insert (self->parameters, argv [idx], ZARG_PARAM_EMPTY);
            }
        }
        idx ++;
    }

    return self;
}
开发者ID:luccasmenezes,项目名称:czmq,代码行数:43,代码来源:zargs.c

示例15: pipe_new

static pipe_t *
pipe_new (server_t *server, const char *name)
{
    pipe_t *self = (pipe_t *) zmalloc (sizeof (pipe_t));
    self->name = strdup (name);
    self->server = server;
    zhash_insert (server->pipes, name, self);
    zhash_freefn (server->pipes, name, s_delete_pipe);
    return self;
}
开发者ID:henrycpp,项目名称:zbroker,代码行数:10,代码来源:zpipes_server.c


注:本文中的zhash_insert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。