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


C++ zlist_size函数代码示例

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


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

示例1: zdir_remove

void
zdir_remove (zdir_t *self, bool force)
{
    //  If forced, remove all subdirectories and files
    if (force) {
        zfile_t *file = (zfile_t *) zlist_pop (self->files);
        while (file) {
            zfile_remove (file);
            zfile_destroy (&file);
            file = (zfile_t *) zlist_pop (self->files);
        }
        zdir_t *subdir = (zdir_t *) zlist_pop (self->subdirs);
        while (subdir) {
            zdir_remove (subdir, force);
            zdir_destroy (&subdir);
            subdir = (zdir_t *) zlist_pop (self->subdirs);
        }
        self->cursize = 0;
        self->count = 0;
    }
    //  Remove if empty
    if (zlist_size (self->files) == 0
    &&  zlist_size (self->subdirs) == 0)
        zsys_dir_delete (self->path);
}
开发者ID:diorcety,项目名称:czmq,代码行数:25,代码来源:zdir.c

示例2: zmsg_send

int
zmsg_send (zmsg_t **self_p, void *dest)
{
    assert (self_p);
    assert (dest);
    zmsg_t *self = *self_p;

    int rc = 0;
    void *handle = zsock_resolve (dest);
    if (self) {
        assert (zmsg_is (self));
        if (zlist_size (self->frames) == 0)
            return -1;          //  Sending an empty message is an error
        
        zframe_t *frame = (zframe_t *) zlist_pop (self->frames);
        while (frame) {
            rc = zframe_send (&frame, handle,
                zlist_size (self->frames)? ZFRAME_MORE: 0);
            if (rc != 0)
                break;
            frame = (zframe_t *) zlist_pop (self->frames);
        }
        zmsg_destroy (self_p);
    }
    return rc;
}
开发者ID:HunterChen,项目名称:czmq,代码行数:26,代码来源:zmsg.c

示例3: zpoller_remove

int
zpoller_remove (zpoller_t *self, void *reader)
{
    assert (self);
    assert (reader);
    int rc = 0;
#ifdef ZMQ_HAVE_POLLER
    void *socket = zsock_resolve (reader);
    if (socket)
        rc = zmq_poller_remove (self->zmq_poller, socket);
    else
        rc = zmq_poller_remove_fd (self->zmq_poller, *(SOCKET *) reader);
#else
    size_t num_readers_before = zlist_size (self->reader_list);
    zlist_remove (self->reader_list, reader); // won't fail with non-existent reader
    size_t num_readers_after = zlist_size (self->reader_list);
    if (num_readers_before != num_readers_after)
        self->need_rebuild = true;
    else {
        errno = EINVAL;
        rc    = -1;
    }
#endif
    return rc;
}
开发者ID:evoskuil,项目名称:czmq,代码行数:25,代码来源:zpoller.c

示例4: s_engine_destroy

static void
s_engine_destroy (engine_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        engine_t *self = *self_p;
        mdp_worker_destroy (&self->worker);

        //  Destroy remaining sell orders
        while (zlist_size (self->sell_orders) > 0) {
            order_t *order = (order_t *) zlist_pop (self->sell_orders);
            s_order_destroy(&order);
        }
        zlist_destroy (&self->sell_orders);

        //  Destroy remaining buy orders
        while (zlist_size (self->buy_orders) > 0) {
            order_t *order = (order_t *) zlist_pop (self->buy_orders);
            s_order_destroy(&order);
        }
        zlist_destroy (&self->buy_orders);

        free (self);
        *self_p = NULL;
    }
}
开发者ID:lerwys,项目名称:majordomo,代码行数:26,代码来源:engine.c

示例5: zloop_destroy

void
zloop_destroy (zloop_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zloop_t *self = *self_p;

        //  Destroy list of readers
        while (zlist_size (self->readers))
            free (zlist_pop (self->readers));
        zlist_destroy (&self->readers);

        //  Destroy list of pollers
        while (zlist_size (self->pollers))
            free (zlist_pop (self->pollers));
        zlist_destroy (&self->pollers);

        //  Destroy list of timers
        while (zlist_size (self->timers))
            free (zlist_pop (self->timers));
        zlist_destroy (&self->timers);

        //  Destroy zombie timer list
        //  Which must always be empty here
        assert (zlist_size (self->zombies) == 0);
        zlist_destroy (&self->zombies);

        free (self->pollset);
        free (self->readact);
        free (self->pollact);
        free (self);
        *self_p = NULL;
    }
}
开发者ID:TomorrowToday,项目名称:czmq,代码行数:34,代码来源:zloop.c

示例6: main

int main (void)
{
    zctx_t *ctx = zctx_new ();
    void *frontend = zsocket_new (ctx, ZMQ_ROUTER);
    void *backend = zsocket_new (ctx, ZMQ_ROUTER);
    zsocket_bind (frontend, "tcp://*:5555");    //  For clients
    zsocket_bind (backend,  "tcp://*:5556");    //  For workers

    //  Queue of available workers
    zlist_t *workers = zlist_new ();
    
    //  The body of this example is exactly the same as lruqueue2.
    //  .skip
    while (1) {
        zmq_pollitem_t items [] = {
            { backend,  0, ZMQ_POLLIN, 0 },
            { frontend, 0, ZMQ_POLLIN, 0 }
        };
        //  Poll frontend only if we have available workers
        int rc = zmq_poll (items, zlist_size (workers)? 2: 1, -1);
        if (rc == -1)
            break;              //  Interrupted

        //  Handle worker activity on backend
        if (items [0].revents & ZMQ_POLLIN) {
            //  Use worker address for LRU routing
            zmsg_t *msg = zmsg_recv (backend);
            if (!msg)
                break;          //  Interrupted
            zframe_t *address = zmsg_unwrap (msg);
            zlist_append (workers, address);

            //  Forward message to client if it's not a READY
            zframe_t *frame = zmsg_first (msg);
            if (memcmp (zframe_data (frame), LRU_READY, 1) == 0)
                zmsg_destroy (&msg);
            else
                zmsg_send (&msg, frontend);
        }
        if (items [1].revents & ZMQ_POLLIN) {
            //  Get client request, route to first available worker
            zmsg_t *msg = zmsg_recv (frontend);
            if (msg) {
                zmsg_wrap (msg, (zframe_t *) zlist_pop (workers));
                zmsg_send (&msg, backend);
            }
        }
    }
    //  When we're done, clean up properly
    while (zlist_size (workers)) {
        zframe_t *frame = (zframe_t *) zlist_pop (workers);
        zframe_destroy (&frame);
    }
    zlist_destroy (&workers);
    zctx_destroy (&ctx);
    return 0;
    //  .until
}
开发者ID:Carl4,项目名称:zguide,代码行数:58,代码来源:spqueue.c

示例7: broker_check_backlog

// Distribute all backlog messages while are workers available.
// Failed-to-send messages are put back in the backlog.
void
broker_check_backlog (broker_t *self)
{
    while (zlist_size (self->backlog) && zlist_size (self->executor_lb)) {
        zmsg_t *backlog_msg = zlist_pop (self->backlog);
        if (0 != broker_send_to_executor (self, backlog_msg))
            zlist_append (self->backlog, backlog_msg);
    }
}
开发者ID:emef,项目名称:sprk,代码行数:11,代码来源:broker.c

示例8: s_on_read_timer

static int
s_on_read_timer (zloop_t *loop, int timer_id, void *arg)
{
    zdir_watch_t *watch = (zdir_watch_t *) arg;

    void *data;
    for (data = zhash_first (watch->subs); data != NULL; data = zhash_next (watch->subs))
    {
        zdir_watch_sub_t *sub = (zdir_watch_sub_t *) data;

        zdir_t *new_dir = zdir_new (zdir_path (sub->dir), NULL);
        if (!new_dir) {
            if (watch->verbose)
                zsys_error ("zdir_watch: Unable to create new zdir for path %s", zdir_path (sub->dir));
            continue;
        }

        // Determine if anything has changed.
        zlist_t *diff = zdir_diff (sub->dir, new_dir, "");

        // Do memory management before error handling...
        zdir_destroy (&sub->dir);
        sub->dir = new_dir;

        if (!diff) {
            if (watch->verbose)
                zsys_error ("zdir_watch: Unable to create diff for path %s", zdir_path (sub->dir));
            continue;
        }

        if (zlist_size (diff) > 0) {
            if (watch->verbose) {
                zdir_patch_t *patch = (zdir_patch_t *) zlist_first (diff);

                zsys_info ("zdir_watch: Found %d changes in %s:", zlist_size (diff), zdir_path (sub->dir));
                while (patch)
                {
                    zsys_info ("zdir_watch:   %s %s", zfile_filename (zdir_patch_file (patch), NULL), zdir_patch_op (patch) == ZDIR_PATCH_CREATE? "created": "deleted");
                    patch = (zdir_patch_t *) zlist_next (diff);
                }
            }

            if (zsock_send (watch->pipe, "sp", zdir_path (sub->dir), diff) != 0) {
                if (watch->verbose)
                    zsys_error ("zdir_watch: Unable to send patch list for path %s", zdir_path (sub->dir));
                zlist_destroy (&diff);
            }

            // Successfully sent `diff` list - now owned by receiver
        }
        else {
            zlist_destroy (&diff);
        }
    }

    return 0;
}
开发者ID:diorcety,项目名称:czmq,代码行数:57,代码来源:zdir.c

示例9: subscriber_sub_socket_new

static
zsock_t* subscriber_sub_socket_new(subscriber_state_t *state)
{
    zsock_t *socket = zsock_new(ZMQ_SUB);
    assert(socket);
    zsock_set_rcvhwm(socket, state->rcv_hwm);

    // set subscription
    if (!state->subscriptions || zlist_size(state->subscriptions) == 0) {
        if (!state->subscriptions)
            state->subscriptions = zlist_new();
        zlist_append(state->subscriptions, zconfig_resolve(state->config, "/logjam/subscription", ""));
    }

    char *subscription = zlist_first(state->subscriptions);
    bool subscribed_to_all = false;
    while (subscription) {
        printf("[I] subscriber: subscribing to '%s'\n", subscription);
        if (streq(subscription, ""))
            subscribed_to_all = true;
        zsock_set_subscribe(socket, subscription);
        subscription = zlist_next(state->subscriptions);
    }
    if (!subscribed_to_all)
        zsock_set_subscribe(socket, "heartbeat");

    if (!state->devices || zlist_size(state->devices) == 0) {
        // convert config file to list of devices
        if (!state->devices)
            state->devices = zlist_new();
        zconfig_t *endpoints = zconfig_locate(state->config, "/logjam/endpoints");
        if (!endpoints) {
            zlist_append(state->devices, "tcp://localhost:9606");
        } else {
            zconfig_t *endpoint = zconfig_child(endpoints);
            while (endpoint) {
                char *spec = zconfig_value(endpoint);
                char *new_spec = augment_zmq_connection_spec(spec, 9606);
                zlist_append(state->devices, new_spec);
                endpoint = zconfig_next(endpoint);
            }
        }
    }

    char* device = zlist_first(state->devices);
    while (device) {
        printf("[I] subscriber: connecting SUB socket to logjam-device via %s\n", device);
        int rc = zsock_connect(socket, "%s", device);
        log_zmq_error(rc, __FILE__, __LINE__);
        assert(rc == 0);
        device = zlist_next(state->devices);
    }

    return socket;
}
开发者ID:skaes,项目名称:logjam-tools,代码行数:55,代码来源:graylog-forwarder-subscriber.c

示例10: kdt_point_equal_float

bool
kdt_point_equal_float (kdt_point_t *A, kdt_point_t *B) {
    int n_components_A = zlist_size (A->list);
    int n_components_B = zlist_size (B->list);
    assert (n_components_A == n_components_B);
    bool still_equal = true;
    for (int counter = 0; counter < n_components_A; counter++) {
        still_equal = ( kdt_point_index_float (A, counter) == kdt_point_index_float (B, counter) );
        if (!still_equal)
            break;
    }
    return still_equal;
}
开发者ID:youralien,项目名称:kdtree-in-c,代码行数:13,代码来源:kdt_point.c

示例11: START_TEST

END_TEST



//  --------------------------------------------------------------------------
/// Try to _get () a zlist_t * without any values
START_TEST(test_msg_get_l_empty)
{
    sam_selftest_introduce ("test_msg_get_l_empty");

    zmsg_t *zmsg = zmsg_new ();

    if (zmsg_pushstr (zmsg, "0")) {
        ck_abort_msg ("could not build zmsg");
    }

    sam_msg_t *msg = sam_msg_new (&zmsg);
    ck_assert_int_eq (sam_msg_size (msg), 1);

    zlist_t *list;
    int rc = sam_msg_get (msg, "l", &list);
    ck_assert_int_eq (rc, 0);
    ck_assert_int_eq (sam_msg_size (msg), 1);
    ck_assert_int_eq (zlist_size (list), 0);

    zlist_destroy (&list);
    sam_msg_destroy (&msg);
}
开发者ID:dreadworks,项目名称:samwise,代码行数:28,代码来源:sam_msg_test.c

示例12: peering_raise

static void
peering_raise (peering_t *self)
{
    vocket_t *vocket = self->vocket;
    driver_t *driver = self->driver;
    if (driver->verbose)
        zclock_log ("I: (tcp) bring up peering to %s", self->address);

    if (!self->alive) {
        self->alive = TRUE;
        zlist_append (vocket->live_peerings, self);

        //  Send ZMTP handshake, which is an empty message
        zmq_msg_t msg;
        zmq_msg_init_size (&msg, 0);
        s_queue_output (self, &msg, FALSE);

        //  If we can now route to peerings, start reading from msgpipe
        if (zlist_size (vocket->live_peerings) == vocket->min_peerings) {
            //  Ask reactor to start monitoring vocket's msgpipe pipe
            zmq_pollitem_t item = { vocket->msgpipe, 0, ZMQ_POLLIN, 0 };
            zloop_poller (driver->loop, &item, s_vocket_input, vocket);
        }
    }
}
开发者ID:imatix,项目名称:vtx,代码行数:25,代码来源:vtx_tcp.c

示例13: multi_job_check

void multi_job_check (struct queue *queue)
{

    zlist_t *newjobs;
    json_t *jobs;

    ok (queue_size (queue) == 0,
        "queue is initially empty");
    if (!(jobs = json_pack ("[{s:I s:i s:i s:f s:i},"
                             "{s:I s:i s:i s:f s:i}]",
                            "id", 1,
                            "priority", 10,
                            "userid", 42,
                            "t_submit", 1.0,
                            "flags", 0,
                            "id", 2,
                            "priority", 11,
                            "userid", 43,
                            "t_submit", 1.1,
                            "flags", 1)))
        BAIL_OUT ("json_pack() failed");

    newjobs = submit_enqueue_jobs (queue, jobs);
    ok (newjobs != NULL,
        "submit_enqueue_jobs works");
    ok (queue_size (queue) == 2,
        "queue contains 2 jobs");
    ok (zlist_size (newjobs) == 2,
        "newjobs contains 2 jobs");
    submit_enqueue_jobs_cleanup (queue, newjobs);
    ok (queue_size (queue) == 0,
        "submit_enqueue_jobs_cleanup removed queue entries");

    json_decref (jobs);
}
开发者ID:flux-framework,项目名称:flux-core,代码行数:35,代码来源:submit.c

示例14: rrwrk_print

void rrwrk_print(rrwrk_t *self)
{
    printf("\n=========================================================================\n");
    printf("W: live %Zd, hb %d\n", self->liveness, self->heartbeat);
    printf("W: waiting list %Zd\n", zlist_size(self->data));
    printf("W: received %Zd, finished %Zd\n", self->total_received, self->total_finished);
}
开发者ID:PerilousApricot,项目名称:lstore-toolbox,代码行数:7,代码来源:rr_wrk.c

示例15: zmsg_send

int
zmsg_send (zmsg_t **self_p, void *dest)
{
    assert (self_p);
    assert (dest);
    zmsg_t *self = *self_p;

    int rc = 0;
    if (self) {
        assert (zmsg_is (self));
        bool sent_some = false;
        zframe_t *frame;
        while ((frame = (zframe_t *) zlist_head (self->frames))) {
            rc = zframe_send (&frame, dest,
                              zlist_size (self->frames) > 1 ?
                                      ZFRAME_MORE : 0);
            if (rc != 0) {
                if (errno == EINTR && sent_some)
                    continue;
                else
                    break;
            }
            sent_some = true;
            (void) zlist_pop (self->frames);
        }
        if (rc == 0)
            zmsg_destroy (self_p);
    }
    return rc;
}
开发者ID:hellermf,项目名称:lstore-release,代码行数:30,代码来源:zmsg.c


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