X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/a4175b2e216a20b86cc872dea8a08005c60617a5..4b9798f44ae94deabf87dd534337b55259272950:/lock_server_cache_rsm.cc diff --git a/lock_server_cache_rsm.cc b/lock_server_cache_rsm.cc index c3f75e8..8f3cf2b 100644 --- a/lock_server_cache_rsm.cc +++ b/lock_server_cache_rsm.cc @@ -20,6 +20,10 @@ lock_state::lock_state(): { } +lock_state::lock_state(const lock_state &other) { + *this = other; +} + lock_state& lock_state::operator=(const lock_state& o) { held = o.held; held_by = o.held_by; @@ -34,50 +38,14 @@ ostringstream & operator<<(ostringstream &o, const pair &d) { return o; } -template -marshall & operator<<(marshall &m, const list &d) { - m << vector(d.begin(), d.end()); - return m; -} - -template -unmarshall & operator>>(unmarshall &u, list &d) { - vector v; - u >> v; - d.assign(v.begin(), v.end()); - return u; -} - - -template -marshall & operator<<(marshall &m, const pair &d) { - m << d.first; - m << d.second; - return m; -} - -template -unmarshall & operator>>(unmarshall &u, pair &d) { - u >> d.first; - u >> d.second; - return u; -} - marshall & operator<<(marshall &m, const lock_state &d) { - m << d.held; - m << d.held_by; - m << d.wanted_by; - return m; + return m << d.held << d.held_by << d.wanted_by; } unmarshall & operator>>(unmarshall &u, lock_state &d) { - u >> d.held; - u >> d.held_by; - u >> d.wanted_by; - return u; + return u >> d.held >> d.held_by >> d.wanted_by; } - lock_state & lock_server_cache_rsm::get_lock_state(lock_protocol::lockid_t lid) { lock sl(lock_table_lock); // by the semantics of map, this will create @@ -113,7 +81,7 @@ void lock_server_cache_rsm::revoker() { proxy = handle(held_by.first).safebind(); if (proxy) { int r; - rlock_protocol::status ret = proxy->call(rlock_protocol::revoke, lid, held_by.second, r); + rlock_protocol::status ret = proxy->call(rlock_protocol::revoke, r, lid, held_by.second); LOG("Revoke returned " << ret); } } @@ -145,13 +113,13 @@ void lock_server_cache_rsm::retryer() { proxy = handle(front.first).safebind(); if (proxy) { int r; - ret = proxy->call(rlock_protocol::retry, lid, front.second, r); + ret = proxy->call(rlock_protocol::retry, r, lid, front.second); LOG("Retry returned " << ret); } } } -int lock_server_cache_rsm::acquire(lock_protocol::lockid_t lid, string id, lock_protocol::xid_t xid, int &) { +int lock_server_cache_rsm::acquire(int &r, lock_protocol::lockid_t lid, string id, lock_protocol::xid_t xid) { LOG_FUNC_ENTER_SERVER; holder h = holder(id, xid); lock_state &st = get_lock_state(lid); @@ -209,7 +177,7 @@ int lock_server_cache_rsm::acquire(lock_protocol::lockid_t lid, string id, lock_ return lock_protocol::RETRY; } -int lock_server_cache_rsm::release(lock_protocol::lockid_t lid, callback id, lock_protocol::xid_t xid, int &r) { +int lock_server_cache_rsm::release(int &r, lock_protocol::lockid_t lid, callback id, lock_protocol::xid_t xid) { LOG_FUNC_ENTER_SERVER; lock_state &st = get_lock_state(lid); lock sl(st.m); @@ -237,7 +205,7 @@ void lock_server_cache_rsm::unmarshal_state(string state) { rep >> lock_table; } -lock_protocol::status lock_server_cache_rsm::stat(lock_protocol::lockid_t lid, int &r) { +lock_protocol::status lock_server_cache_rsm::stat(int &r, lock_protocol::lockid_t lid) { printf("stat request\n"); r = nacquire; return lock_protocol::OK;