5 unique_ptr<rpcc> client;
8 std::mutex client_mutex;
9 hinfo(const string & destination_) : destination(destination_) {}
12 static std::mutex mgr_mutex;
13 static std::map<string, shared_ptr<hinfo>> hmap;
15 void handle::shutdown() {
17 LOG_NONMEMBER << "Shutting down handle manager";
19 p.second->valid = false;
20 LOG_NONMEMBER << "cl " << p.first << " refcnt " << p.second.use_count();
25 handle::handle(const string & destination) : destination_(destination) {
27 h = hmap[destination];
29 h = (hmap[destination] = std::make_shared<hinfo>(destination));
32 rpcc * handle::safebind() {
35 lock cl(h->client_mutex);
39 unique_ptr<rpcc> client(new rpcc(h->destination));
40 LOG << "bind(\"" << h->destination << "\")";
41 int ret = client->bind(milliseconds(1000));
43 LOG << "bind failure! " << h->destination << " " << ret;
46 LOG << "bind succeeded " << h->destination;
47 h->client = std::move(client);
50 return h->client.get();
53 void handle::invalidate() {
56 if (hmap.find(destination_) != hmap.end()) {
57 hmap[destination_]->valid = false;
58 LOG << "cl " << destination_ << " refcnt " << hmap[destination_].use_count();
59 hmap.erase(destination_);