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"
13 #include "rsm_client.h"
15 class lock_release_user {
17 virtual void dorelease(lock_protocol::lockid_t) = 0;
18 virtual ~lock_release_user() {};
26 typedef string callback;
39 std::thread::id held_by;
40 list<std::thread::id> wanted_by;
42 map<std::thread::id, std::condition_variable> c;
43 lock_protocol::xid_t xid;
46 void signal(std::thread::id who);
49 typedef map<lock_protocol::lockid_t, lock_state> lock_map;
51 class lock_client_cache_rsm;
53 // Clients that caches locks. The server can revoke locks using
54 // lock_revoke_server.
55 class lock_client_cache_rsm : public lock_client {
57 std::thread releaser_thread;
59 class lock_release_user *lu;
64 lock_protocol::xid_t xid;
65 fifo<lock_protocol::lockid_t> release_fifo;
66 mutex lock_table_lock;
68 lock_state &get_lock_state(lock_protocol::lockid_t lid);
71 lock_client_cache_rsm(string xdst, class lock_release_user *l = 0);
72 virtual ~lock_client_cache_rsm() {};
73 lock_protocol::status acquire(lock_protocol::lockid_t);
74 virtual lock_protocol::status release(lock_protocol::lockid_t);
76 rlock_protocol::status revoke_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
77 rlock_protocol::status retry_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);