bool cached_zk::list(const string& path, vector<string>& out) { out.clear(); scoped_lock lk(m_); std::map<string, std::set<string> >::const_iterator it = list_cache_.find( path); if (it == list_cache_.end()) { // First time, get list to create cache and set the watcher { DLOG(INFO) << "creating cache: " << path; } std::set<string> tmp_list; if (!list_(path, tmp_list)) { return false; } list_cache_[path] = tmp_list; for (std::set<string>::const_iterator i = tmp_list.begin(); i != tmp_list.end(); ++i) { out.push_back(*i); } } else { for (std::set<string>::const_iterator i = it->second.begin(); i != it->second.end(); ++i) { out.push_back(*i); } } return true; }
std::vector<std::string> CTrace::GetParameterList() { std::vector<std::string> list_(ParameterList, ParameterList + NParaList); return list_; }
R operator()(P1 p1, P2 p2, P3 p3) { param_list3<R, P1, P2, P3> list(p1, p2, p3); return list_(f_, list); }
R operator()(P1 p1, P2 p2) { param_list2<R, P1, P2> list(p1, p2); return list_(f_, list); }
R operator()(P1 p1) { param_list1<R, P1> list(p1); return list_(f_, list); }
R operator()() { param_list0<R> list; return list_(f_, list); }
void cached_zk::reload_cache(const string& path) { scoped_lock lk(m_); list_(path, list_cache_[path]); }
static aug_result run_BIN_(int argc, char* argv[], const char* archivename) { aug_mpool* mpool; int flags = 0; mode_t mode = 0; aug_mar* mar; int ch; switch (options_ & (READOPT_ | WRITEOPT_)) { case READOPT_: flags = AUG_RDONLY; break; case WRITEOPT_: flags = AUG_WRONLY; break; case READOPT_ | WRITEOPT_: flags = AUG_RDWR; break; } if (options_ & CREATEOPT_) { flags |= AUG_CREAT; mode = 0666; } mpool = aug_getmpool(aug_tlx); mar = aug_openmar_BIN(mpool, archivename, flags, mode); aug_release(mpool); if (!mar) { aug_perrinfo(aug_tlx, "aug_openmar() failed", NULL); return -1; } while (-1 != (ch = aug_getopt(argc, argv, OPTIONS_))) switch (ch) { case 'c': if (clear_(mar) < 0) { aug_perrinfo(aug_tlx, "failed to " CLEARTEXT_, NULL); goto fail; } break; case 'd': if (del_(mar, aug_optarg) < 0) { aug_perrinfo(aug_tlx, "failed to " DELTEXT_, NULL); goto fail; } break; case 'f': break; case 'g': if (get_(mar, aug_optarg) < 0) { aug_perrinfo(aug_tlx, "failed to " GETTEXT_, NULL); goto fail; } break; case 'i': if (insert_BIN_(mar, aug_optarg) < 0) { aug_perrinfo(aug_tlx, "failed to " INSERTTEXT_, NULL); goto fail; } break; case 'l': if (names_(mar) < 0) { aug_perrinfo(aug_tlx, "failed to " NAMESTEXT_, NULL); goto fail; } break; case 'n': size_(mar); break; case 'o': if (aug_compactmar(mar) < 0) { aug_perrinfo(aug_tlx, "failed to " COMPACTTEXT_, NULL); goto fail; } break; case 'p': if (put_BIN_(mar, aug_optarg) < 0) { aug_perrinfo(aug_tlx, "failed to " PUTTEXT_, NULL); goto fail; } break; case 't': if (list_(mar) < 0) { aug_perrinfo(aug_tlx, "failed to " LISTTEXT_, NULL); goto fail; } break; case 'x': if (extract_(mar, aug_optarg) < 0) { aug_perrinfo(aug_tlx, "failed to " EXTRACTTEXT_, NULL); goto fail; } break; case 'z': if (zero_(mar) < 0) { aug_perrinfo(aug_tlx, "failed to " ZEROTEXT_, NULL); goto fail; } break; case 'h': case '?': default: fprintf(stderr, "unexpected option [-%c]\n", aug_optopt); goto fail; } aug_release(mar); return 0; fail: aug_release(mar); return -1; }
bool zk::list(const string& path, vector<string>& out) { scoped_lock lk(m_); return list_(path, out); }
void zk::list(const std::string& path, std::vector<std::string>& out) { scoped_lock lk(m_); list_(path, out); };