X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/a4175b2e216a20b86cc872dea8a08005c60617a5..6b5e09540e9392a7015fae1ad3b01b0973600ff2:/lock_protocol.h diff --git a/lock_protocol.h b/lock_protocol.h index 61f0998..5589c07 100644 --- a/lock_protocol.h +++ b/lock_protocol.h @@ -3,29 +3,27 @@ #ifndef lock_protocol_h #define lock_protocol_h +#include "types.h" #include "rpc/rpc.h" -#include -class lock_protocol { - public: - enum xxstatus { OK, RETRY, RPCERR, NOENT, IOERR }; - typedef int status; - typedef std::string lockid_t; - typedef unsigned long long xid_t; - enum rpc_numbers { - acquire = 0x7001, - release, - stat - }; +typedef string callback_t; + +namespace lock_protocol { + enum status : rpc_protocol::status { OK, RETRY, RPCERR, NOENT, IOERR }; + using lockid_t = string; + using xid_t = uint64_t; + REMOTE_PROCEDURE_BASE(0x7000); + REMOTE_PROCEDURE(1, acquire, (int &, lockid_t, callback_t, xid_t)); + REMOTE_PROCEDURE(2, release, (int &, lockid_t, callback_t, xid_t)); + REMOTE_PROCEDURE(3, stat, (int &, lockid_t, callback_t)); }; -class rlock_protocol { - public: - enum xxstatus { OK, RPCERR }; - typedef int status; - enum rpc_numbers { - revoke = 0x8001, - retry = 0x8002 - }; +namespace rlock_protocol { + using lockid_t = lock_protocol::lockid_t; + using xid_t = lock_protocol::xid_t; + enum status : rpc_protocol::status { OK, RPCERR }; + REMOTE_PROCEDURE_BASE(0x8000); + REMOTE_PROCEDURE(1, revoke, (int &, lockid_t, xid_t)); + REMOTE_PROCEDURE(2, retry, (int &, lockid_t, xid_t)); }; #endif