More logging clean-ups. Static type-checking for RPC calls and
[invirt/third/libt4.git] / handle.h
index 6b042fb..f4df61a 100644 (file)
--- a/handle.h
+++ b/handle.h
@@ -1,5 +1,5 @@
 // manage a cache of RPC connections.
-// assuming cid is a std::string holding the
+// assuming cid is a string holding the
 // host:port of the RPC server you want
 // to talk to:
 //
 #ifndef handle_h
 #define handle_h
 
-#include <string>
-#include <vector>
+#include "types.h"
 #include "rpc/rpc.h"
 
-struct hinfo {
-  rpcc *cl;
-  int refcnt;
-  bool del;
-  std::string m;
-  std::mutex cl_mutex;
-};
+class hinfo;
 
 class handle {
     private:
-        struct hinfo *h;
+        shared_ptr<hinfo> h;
     public:
-        handle(std::string m);
-        ~handle();
+        handle(const string & m);
         /* safebind will try to bind with the rpc server on the first call.
          * Since bind may block, the caller probably should not hold a mutex
          * when calling safebind.
@@ -60,20 +52,10 @@ class handle {
          *   }
          */
         rpcc *safebind();
-};
 
-class handle_mgr {
-    private:
-        std::mutex handle_mutex;
-        std::map<std::string, struct hinfo *> hmap;
-    public:
-        handle_mgr();
-        struct hinfo *get_handle(std::string m);
-        void done_handle(struct hinfo *h);
-        void delete_handle(std::string m);
-        void delete_handle_wo(std::string m);
+        void invalidate();
 };
 
-extern class handle_mgr mgr;
+void invalidate_handle(const string & m);
 
 #endif