本文整理汇总了C++中zlist_next函数的典型用法代码示例。如果您正苦于以下问题:C++ zlist_next函数的具体用法?C++ zlist_next怎么用?C++ zlist_next使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zlist_next函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zsync_node_new
static zsync_node_t *
zsync_node_new ()
{
int rc;
zsync_node_t *self = (zsync_node_t *) zmalloc (sizeof (zsync_node_t));
self->ctx = zctx_new ();
assert (self->ctx);
self->zyre = zyre_new (self->ctx);
assert (self->zyre);
// Obtain permanent UUID
self->own_uuid = zuuid_new ();
if (zsys_file_exists (UUID_FILE)) {
// Read uuid from file
zfile_t *uuid_file = zfile_new (".", UUID_FILE);
int rc = zfile_input (uuid_file); // open file for reading
assert (rc == 0);
zchunk_t *uuid_chunk = zfile_read (uuid_file, 16, 0);
assert (zchunk_size (uuid_chunk) == 16); // make sure read succeeded
zuuid_set (self->own_uuid, zchunk_data (uuid_chunk));
zfile_destroy (&uuid_file);
} else {
// Write uuid to file
zfile_t *uuid_file = zfile_new (".", UUID_FILE);
rc = zfile_output (uuid_file); // open file for writing
assert (rc == 0);
zchunk_t *uuid_bin = zchunk_new ( zuuid_data (self->own_uuid), 16);
rc = zfile_write (uuid_file, uuid_bin, 0);
assert (rc == 0);
zfile_destroy (&uuid_file);
}
// Obtain peers and states
self->peers = zlist_new ();
if (zsys_file_exists (PEER_STATES_FILE)) {
zhash_t *peer_states = zhash_new ();
int rc = zhash_load (peer_states, PEER_STATES_FILE);
assert (rc == 0);
zlist_t *uuids = zhash_keys (peer_states);
char *uuid = zlist_first (uuids);
while (uuid) {
char * state_str = zhash_lookup (peer_states, uuid);
uint64_t state;
sscanf (state_str, "%"SCNd64, &state);
zlist_append (self->peers, zsync_peer_new (uuid, state));
uuid = zlist_next (uuids);
}
}
self->zyre_peers = zhash_new ();
self->terminated = false;
return self;
}
示例2: s_rebuild_pollset
static int
s_rebuild_pollset (zloop_t *self)
{
free (self->pollset);
free (self->readact);
free (self->pollact);
self->pollset = NULL;
self->readact = NULL;
self->pollact = NULL;
self->poll_size = zlist_size (self->readers) + zlist_size (self->pollers);
self->pollset = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof (zmq_pollitem_t));
if (!self->pollset)
return -1;
self->readact = (s_reader_t *) zmalloc (self->poll_size * sizeof (s_reader_t));
if (!self->readact)
return -1;
self->pollact = (s_poller_t *) zmalloc (self->poll_size * sizeof (s_poller_t));
if (!self->pollact)
return -1;
s_reader_t *reader = (s_reader_t *) zlist_first (self->readers);
uint item_nbr = 0;
while (reader) {
zmq_pollitem_t poll_item = { zsock_resolve (reader->sock), 0, ZMQ_POLLIN };
self->pollset [item_nbr] = poll_item;
self->readact [item_nbr] = *reader;
item_nbr++;
reader = (s_reader_t *) zlist_next (self->readers);
}
s_poller_t *poller = (s_poller_t *) zlist_first (self->pollers);
while (poller) {
self->pollset [item_nbr] = poller->item;
self->pollact [item_nbr] = *poller;
item_nbr++;
poller = (s_poller_t *) zlist_next (self->pollers);
}
self->need_rebuild = false;
return 0;
}
示例3: zlist_first
static flux_msg_handler_t *find_waiting_handler (struct dispatch *d,
const flux_msg_t *msg)
{
flux_msg_handler_t *w = zlist_first (d->waiters);
while (w) {
if (flux_msg_cmp (msg, w->wait_match))
break;
w = zlist_next (d->waiters);
}
return w;
}
示例4: s_service_enable_command
static void
s_service_enable_command (service_t *self, const char *command)
{
char *item = (char *) zlist_first (self->blacklist);
while (item && !streq (item, command))
item = (char *) zlist_next (self->blacklist);
if (item) {
zlist_remove (self->blacklist, item);
free (item);
}
}
示例5: HHVM_METHOD
Array HHVM_METHOD(ZMQCert, getMetaKeys) {
auto metaKeys = zcert_meta_keys(Native::data<ZMQCert>(this_)->zcert);
auto metaKey = zlist_first(metaKeys);
PackedArrayInit ret(4);
while (metaKey != nullptr) {
ret.append(String((char*)metaKey, CopyString));
metaKey = zlist_next(metaKeys);
}
return ret.toArray();
}
示例6: to_vector
std::vector<std::string> to_vector(zlist_t* list) const
{
std::vector<std::string> ret;
void* cursor = zlist_first(list);
while (cursor != NULL)
{
ret.emplace_back(static_cast<char*>(cursor));
cursor = zlist_next(list);
}
return ret;
}
示例7: match_sub
static bool match_sub (module_t *p, const char *topic)
{
char *s = zlist_first (p->subs);
while (s) {
if (!strncmp (topic, s, strlen (s)))
return true;
s = zlist_next (p->subs);
}
return false;
}
示例8: get_next_subscription
static void
get_next_subscription (client_t *self)
{
sub_t *sub = (sub_t *) zlist_next (self->subs);
if (sub) {
fmq_msg_path_set (self->request, sub->path);
self->next_event = ok_event;
}
else
self->next_event = finished_event;
}
示例9: subprocess_manager_find_pid
static struct subprocess *
subprocess_manager_find_pid (struct subprocess_manager *sm, pid_t pid)
{
struct subprocess *p = zlist_first (sm->processes);
while (p) {
if (p->pid == pid)
return (p);
p = zlist_next (sm->processes);
}
return (NULL);
}
示例10: emit_command_list_category
static void emit_command_list_category (zhash_t *zh, const char *cat, FILE *fp)
{
struct cmdhelp *c;
zlist_t *zl = zhash_lookup (zh, cat);
fprintf (fp, "Common commands from flux-%s:\n", cat);
c = zlist_first (zl);
while (c) {
fprintf (fp, " %-18s %s\n", c->cmd, c->description);
c = zlist_next (zl);
}
}
示例11: send_event
/* Broadcast event using all senders.
* Log failure, but don't abort the event at this point.
*/
static void send_event (struct publisher *pub, const flux_msg_t *msg)
{
struct sender *sender;
sender = zlist_first (pub->senders);
while (sender != NULL) {
if (sender->send (sender->arg, msg) < 0)
flux_log_error (pub->h, "%s: sender=%s",
__FUNCTION__, sender->name);
sender = zlist_next (pub->senders);
}
}
示例12: mount_sub_store
static void
mount_sub_store (mount_t *self, client_t *client, fmq_msg_t *request)
{
// Store subscription along with any previous ones
// Coalesce subscriptions that are on same path
char *path = fmq_msg_path (request);
sub_t *sub = (sub_t *) zlist_first (self->subs);
while (sub) {
if (client == sub->client) {
// If old subscription is superset/same as new, ignore new
if (strncmp (path, sub->path, strlen (sub->path)) == 0)
return;
else
// If new subscription is superset of old one, remove old
if (strncmp (sub->path, path, strlen (path)) == 0) {
zlist_remove (self->subs, sub);
sub_destroy (&sub);
sub = (sub_t *) zlist_first (self->subs);
}
else
sub = (sub_t *) zlist_next (self->subs);
}
else
sub = (sub_t *) zlist_next (self->subs);
}
// New subscription for this client, append to our list
sub = sub_new (client, path, fmq_msg_cache (request));
zlist_append (self->subs, sub);
// If client requested resync, send full mount contents now
if (fmq_msg_options_number (client->request, "RESYNC", 0) == 1) {
zlist_t *patches = fmq_dir_resync (self->dir, self->alias);
while (zlist_size (patches)) {
fmq_patch_t *patch = (fmq_patch_t *) zlist_pop (patches);
sub_patch_add (sub, patch);
fmq_patch_destroy (&patch);
}
zlist_destroy (&patches);
}
}
示例13: invoke_cbs
static int invoke_cbs (flux_t *h, int64_t j, json_object *jcb, int errnum)
{
int rc = 0;
cb_pair_t *c = NULL;
jscctx_t *ctx = getctx (h);
for (c = zlist_first (ctx->callbacks); c; c = zlist_next (ctx->callbacks)) {
if (c->cb (jcb, c->arg, errnum) < 0) {
flux_log (h, LOG_ERR, "callback returns an error");
rc = -1;
}
}
return rc;
}
示例14: zlist_first
static subscription_t *subscription_lookup (client_t *c, int type,
const char *topic)
{
subscription_t *sub;
sub = zlist_first (c->subscriptions);
while (sub) {
if (sub->type == type && !strcmp (sub->topic, topic))
return sub;
sub = zlist_next (c->subscriptions);
}
return NULL;
}
示例15: zsync_node_peers_lookup
static zsync_peer_t *
zsync_node_peers_lookup (zsync_node_t *self, char *uuid)
{
assert (self);
zsync_peer_t *peer = zlist_first (self->peers);
while (peer) {
if (streq (zsync_peer_uuid (peer), uuid)) {
return peer;
}
peer = zlist_next (self->peers);
}
return NULL;
}