1 // lock client interface.
8 #include "include/types.h"
9 #include "include/lock_protocol.h"
10 #include "include/rpc/fifo.h"
11 #include "include/rsm_client.h"
12 #include "include/maybe.h"
14 // Clients that caches locks. The server can revoke locks using
15 // lock_revoke_server.
28 std::thread::id held_by;
29 std::list<thread::id> wanted_by;
31 std::map<thread::id, cond> c;
32 lock_protocol::xid_t xid;
33 void wait(lock & mutex_lock);
35 void signal(thread::id who);
38 unique_ptr<rpcs> rlsrpc;
39 thread releaser_thread;
40 unique_ptr<rsm_client> rsmc;
45 lock_protocol::xid_t next_xid=0;
46 fifo<maybe<lock_protocol::lockid_t>> release_fifo;
47 std::mutex lock_table_lock;
48 std::map<lock_protocol::lockid_t, lock_state> lock_table;
49 lock_state & get_lock_state(lock_protocol::lockid_t lid);
51 lock_client(string xdst);
53 lock_protocol::status acquire(lock_protocol::lockid_t);
54 lock_protocol::status release(lock_protocol::lockid_t);
56 rlock_protocol::status revoke_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
57 rlock_protocol::status retry_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
66 struct _t4_lock_client;
67 typedef struct _t4_lock_client t4_lock_client;
77 typedef int t4_status;
79 typedef const char * t4_lockid_t;
81 t4_lock_client *t4_lock_client_new(const char *dst);
82 void t4_lock_client_delete(t4_lock_client *);
83 t4_status t4_lock_client_acquire(t4_lock_client *, t4_lockid_t);
84 t4_status t4_lock_client_release(t4_lock_client *, t4_lockid_t);