1 // lock client interface.
10 #include "lock_protocol.h"
12 #include "lang/verify.h"
14 #include "rsm_client.h"
16 class lock_release_user {
18 virtual void dorelease(lock_protocol::lockid_t) = 0;
19 virtual ~lock_release_user() {};
27 typedef string callback;
40 std::thread::id held_by;
41 list<std::thread::id> wanted_by;
43 map<std::thread::id, std::condition_variable> c;
44 lock_protocol::xid_t xid;
47 void signal(std::thread::id who);
50 typedef map<lock_protocol::lockid_t, lock_state> lock_map;
52 // Clients that caches locks. The server can revoke locks using
53 // lock_revoke_server.
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(string xdst, class lock_release_user *l = 0);
73 lock_protocol::status acquire(lock_protocol::lockid_t);
74 lock_protocol::status release(lock_protocol::lockid_t);
75 int stat(lock_protocol::lockid_t);
77 rlock_protocol::status revoke_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
78 rlock_protocol::status retry_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
85 struct _t4_lock_client;
86 typedef struct _t4_lock_client t4_lock_client;
96 typedef int t4_status;
98 typedef const char * t4_lockid_t;
100 t4_lock_client *t4_lock_client_new(const char *dst);
101 void t4_lock_client_delete(t4_lock_client *);
102 t4_status t4_lock_client_acquire(t4_lock_client *, t4_lockid_t);
103 t4_status t4_lock_client_release(t4_lock_client *, t4_lockid_t);
104 t4_status t4_lock_client_stat(t4_lock_client *, t4_lockid_t);