5 unique_ptr<rpcc> client;
9 hinfo(const string & destination_) : destination(destination_) {}
12 static mutex mgr_mutex;
13 static map<string, shared_ptr<hinfo>> hmap;
15 handle::handle(const string & destination) : destination_(destination) {
17 h = hmap[destination];
19 h = (hmap[destination] = make_shared<hinfo>(destination));
22 rpcc * handle::safebind() {
25 lock cl(h->client_mutex);
29 unique_ptr<rpcc> client(new rpcc(h->destination));
30 LOG << "bind(\"" << h->destination << "\")";
31 int ret = client->bind(milliseconds(1000));
33 LOG << "bind failure! " << h->destination << " " << ret;
36 LOG << "bind succeeded " << h->destination;
37 h->client = std::move(client);
40 return h->client.get();
43 void handle::invalidate() {
46 if (hmap.find(destination_) != hmap.end()) {
47 hmap[destination_]->valid = false;
48 LOG << "cl " << destination_ << " refcnt " << hmap[destination_].use_count();
49 hmap.erase(destination_);