1 // lock client interface.
3 #ifndef lock_client_cache_rsm_h
5 #define lock_client_cache_rsm_h
8 #include "lock_protocol.h"
10 #include "lock_client.h"
11 #include "lang/verify.h"
14 #include "rsm_client.h"
16 // Classes that inherit lock_release_user can override dorelease so that
17 // that they will be called when lock_client releases a lock.
18 // You will not need to do anything with this class until Lab 5.
19 class lock_release_user {
21 virtual void dorelease(lock_protocol::lockid_t) = 0;
22 virtual ~lock_release_user() {};
27 typedef string callback;
41 list<pthread_t> wanted_by;
43 map<pthread_t, cond> c;
44 lock_protocol::xid_t xid;
47 void signal(pthread_t who);
50 typedef map<lock_protocol::lockid_t, lock_state> lock_map;
52 class lock_client_cache_rsm;
54 // Clients that caches locks. The server can revoke locks using
55 // lock_revoke_server.
56 class lock_client_cache_rsm : public lock_client {
58 pthread_t releaser_thread;
60 class lock_release_user *lu;
65 lock_protocol::xid_t xid;
66 fifo<lock_protocol::lockid_t> release_fifo;
67 mutex lock_table_lock;
69 lock_state &get_lock_state(lock_protocol::lockid_t lid);
72 lock_client_cache_rsm(string xdst, class lock_release_user *l = 0);
73 virtual ~lock_client_cache_rsm() {};
74 lock_protocol::status acquire(lock_protocol::lockid_t);
75 virtual lock_protocol::status release(lock_protocol::lockid_t);
77 rlock_protocol::status revoke_handler(lock_protocol::lockid_t, lock_protocol::xid_t, int &);
78 rlock_protocol::status retry_handler(lock_protocol::lockid_t, lock_protocol::xid_t, int &);