4 #include "include/types.h"
5 #include "include/lock_protocol.h"
6 #include "include/rsm.h"
7 #include "include/rpc/fifo.h"
9 class lock_server : private rsm_state_transfer {
11 using holder_t=std::pair<callback_t, lock_protocol::xid_t>;
14 inline lock_state() {}
15 lock_state(const lock_state & other);
18 std::list<holder_t> wanted_by;
19 std::map<callback_t, lock_protocol::xid_t> old_requests;
22 MEMBERS(held, held_by, wanted_by)
26 std::mutex lock_table_lock;
27 std::map<lock_protocol::lockid_t, lock_state> lock_table;
28 lock_state & get_lock_state(lock_protocol::lockid_t lid);
29 fifo<lock_protocol::lockid_t> retry_fifo, revoke_fifo;
31 string marshall_state();
32 void unmarshall_state(const string & state);
33 void revoker NORETURN ();
34 void retryer NORETURN ();
37 lock_protocol::status acquire(int &, lock_protocol::lockid_t, const callback_t & id, lock_protocol::xid_t);
38 lock_protocol::status release(int &, lock_protocol::lockid_t, const callback_t & id, lock_protocol::xid_t);