1 // lock client interface.
10 #include "lock_protocol.h"
12 #include "lang/verify.h"
14 #include "rsm_client.h"
17 class lock_release_user {
19 virtual void dorelease(lock_protocol::lockid_t) = 0;
20 virtual ~lock_release_user() {}
39 list<thread::id> wanted_by;
41 map<thread::id, cond> c;
42 lock_protocol::xid_t xid;
43 void wait(lock & mutex_lock);
45 void signal(thread::id who);
48 typedef map<lock_protocol::lockid_t, lock_state> lock_map;
50 // Clients that caches locks. The server can revoke locks using
51 // lock_revoke_server.
55 thread releaser_thread;
57 class lock_release_user *lu;
58 unsigned int rlock_port;
62 lock_protocol::xid_t next_xid;
63 fifo<lock_protocol::lockid_t> release_fifo;
64 mutex lock_table_lock;
66 lock_state &get_lock_state(lock_protocol::lockid_t lid);
68 static unsigned int last_port;
69 lock_client(string xdst, class lock_release_user *l = 0);
71 lock_protocol::status acquire(lock_protocol::lockid_t);
72 lock_protocol::status release(lock_protocol::lockid_t);
73 int stat(lock_protocol::lockid_t);
75 rlock_protocol::status revoke_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
76 rlock_protocol::status retry_handler(int &, lock_protocol::lockid_t, lock_protocol::xid_t);
83 struct _t4_lock_client;
84 typedef struct _t4_lock_client t4_lock_client;
94 typedef int t4_status;
96 typedef const char * t4_lockid_t;
98 t4_lock_client *t4_lock_client_new(const char *dst);
99 void t4_lock_client_delete(t4_lock_client *);
100 t4_status t4_lock_client_acquire(t4_lock_client *, t4_lockid_t);
101 t4_status t4_lock_client_release(t4_lock_client *, t4_lockid_t);
102 t4_status t4_lock_client_stat(t4_lock_client *, t4_lockid_t);