So many changes. Broken.
[invirt/third/libt4.git] / include / lock_client.h
similarity index 63%
rename from lock_client.h
rename to include/lock_client.h
index 9e449f4..64848b5 100644 (file)
@@ -5,59 +5,50 @@
 
 #ifdef __cplusplus
 
-#include "types.h"
-#include "lock_protocol.h"
-#include "rpc/fifo.h"
-#include "rsm_client.h"
-#include "maybe.h"
-
-class lock_release_user {
-    public:
-        virtual void dorelease(lock_protocol::lockid_t) = 0;
-        virtual ~lock_release_user() {}
-};
-
-class lock_state {
-public:
-    enum {
-        none = 0,
-        retrying,
-        free,
-        locked,
-        acquiring,
-        releasing
-    } state = none;
-    std::thread::id held_by;
-    std::list<thread::id> wanted_by;
-    std::mutex m;
-    std::map<thread::id, cond> c;
-    lock_protocol::xid_t xid;
-    void wait(lock & mutex_lock);
-    void signal();
-    void signal(thread::id who);
-};
-
-typedef std::map<lock_protocol::lockid_t, lock_state> lock_map;
+#include "include/types.h"
+#include "include/lock_protocol.h"
+#include "include/rpc/fifo.h"
+#include "include/rsm_client.h"
+#include "include/maybe.h"
 
 // Clients that caches locks.  The server can revoke locks using
 // lock_revoke_server.
 class lock_client {
     private:
+        class lock_state {
+        public:
+            enum {
+                none = 0,
+                retrying,
+                free,
+                locked,
+                acquiring,
+                releasing
+            } state = none;
+            std::thread::id held_by;
+            std::list<thread::id> wanted_by;
+            std::mutex m;
+            std::map<thread::id, cond> c;
+            lock_protocol::xid_t xid;
+            void wait(lock & mutex_lock);
+            void signal();
+            void signal(thread::id who);
+        };
+
         unique_ptr<rpcs> rlsrpc;
         thread releaser_thread;
         unique_ptr<rsm_client> rsmc;
-        lock_release_user *lu;
         in_port_t rlock_port;
         string hostname;
         string id;
         std::mutex xid_mutex;
-        lock_protocol::xid_t next_xid;
+        lock_protocol::xid_t next_xid=0;
         fifo<maybe<lock_protocol::lockid_t>> release_fifo;
         std::mutex lock_table_lock;
-        lock_map lock_table;
+        std::map<lock_protocol::lockid_t, lock_state> lock_table;
         lock_state & get_lock_state(lock_protocol::lockid_t lid);
     public:
-        lock_client(string xdst, lock_release_user *l = 0);
+        lock_client(string xdst);
         ~lock_client();
         lock_protocol::status acquire(lock_protocol::lockid_t);
         lock_protocol::status release(lock_protocol::lockid_t);