1 // lock client interface.
9 #include "lock_protocol.h"
11 #include "rsm_client.h"
14 class lock_release_user {
16 virtual void dorelease(lock_protocol::lockid_t) = 0;
17 virtual ~lock_release_user() {}
30 std::thread::id held_by;
31 std::list<thread::id> wanted_by;
33 std::map<thread::id, cond> c;
34 lock_protocol::xid_t xid;
35 void wait(lock & mutex_lock);
37 void signal(thread::id who);
40 typedef std::map<lock_protocol::lockid_t, lock_state> lock_map;
42 // Clients that caches locks. The server can revoke locks using
43 // lock_revoke_server.
47 unique_ptr<rpcs> rlsrpc;
48 thread releaser_thread;
49 unique_ptr<rsm_client> rsmc;
50 lock_release_user *lu;
55 lock_protocol::xid_t next_xid;
56 fifo<maybe<lock_protocol::lockid_t>> release_fifo;
57 std::mutex lock_table_lock;
59 lock_state & get_lock_state(lock_protocol::lockid_t lid);
61 lock_client(string xdst, lock_release_user *l = 0);
63 lock_protocol::status acquire(lock_protocol::lockid_t);
64 lock_protocol::status release(lock_protocol::lockid_t);
65 int stat(lock_protocol::lockid_t);
67 rlock_protocol::status revoke_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
68 rlock_protocol::status retry_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
77 struct _t4_lock_client;
78 typedef struct _t4_lock_client t4_lock_client;
88 typedef int t4_status;
90 typedef const char * t4_lockid_t;
92 t4_lock_client *t4_lock_client_new(const char *dst);
93 void t4_lock_client_delete(t4_lock_client *);
94 t4_status t4_lock_client_acquire(t4_lock_client *, t4_lockid_t);
95 t4_status t4_lock_client_release(t4_lock_client *, t4_lockid_t);
96 t4_status t4_lock_client_stat(t4_lock_client *, t4_lockid_t);