#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;
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;
// 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;