Major clean-ups. Migrating to C++11.
[invirt/third/libt4.git] / lock_client_cache_rsm.h
index 28b0323..049d18a 100644 (file)
@@ -6,23 +6,22 @@
 
 #include <string>
 #include "lock_protocol.h"
-#include "rpc.h"
+#include "rpc/rpc.h"
 #include "lock_client.h"
 #include "lang/verify.h"
-#include "mutex.h"
 #include "rpc/fifo.h"
 #include "rsm_client.h"
 
-// Classes that inherit lock_release_user can override dorelease so that
-// that they will be called when lock_client releases a lock.
-// You will not need to do anything with this class until Lab 5.
 class lock_release_user {
     public:
         virtual void dorelease(lock_protocol::lockid_t) = 0;
         virtual ~lock_release_user() {};
 };
 
-using namespace std;
+using std::string;
+using std::thread;
+using std::list;
+using std::map;
 
 typedef string callback;
 
@@ -37,14 +36,14 @@ public:
         acquiring,
         releasing
     } state;
-    pthread_t held_by;
-    list<pthread_t> wanted_by;
+    std::thread::id held_by;
+    list<std::thread::id> wanted_by;
     mutex m;
-    map<pthread_t, cond> c;
+    map<std::thread::id, std::condition_variable> c;
     lock_protocol::xid_t xid;
     void wait();
     void signal();
-    void signal(pthread_t who);
+    void signal(std::thread::id who);
 };
 
 typedef map<lock_protocol::lockid_t, lock_state> lock_map;
@@ -55,7 +54,7 @@ class lock_client_cache_rsm;
 // lock_revoke_server.
 class lock_client_cache_rsm : public lock_client {
     private:
-        pthread_t releaser_thread;
+        std::thread releaser_thread;
         rsm_client *rsmc;
         class lock_release_user *lu;
         int rlock_port;