More logging clean-ups. Static type-checking for RPC calls and
[invirt/third/libt4.git] / rsm.h
diff --git a/rsm.h b/rsm.h
index 8fdf2d5..b402bab 100644 (file)
--- a/rsm.h
+++ b/rsm.h
@@ -18,9 +18,9 @@ class rsm_state_transfer {
 
 class rsm : public config_view_change {
     private:
-        void reg1(int proc, handler *);
+        void reg1(rpc_protocol::proc_id_t proc, handler *);
     protected:
-        map<int, handler *> procs;
+        map<rpc_protocol::proc_id_t, handler *> procs;
         unique_ptr<config> cfg;
         rsm_state_transfer *stf = nullptr;
         rpcs *rsmrpc;
@@ -43,7 +43,7 @@ class rsm : public config_view_change {
         bool break2;
 
         rsm_client_protocol::status client_members(vector<string> &r, int i);
-        rsm_protocol::status invoke(int &, int proc, viewstamp vs, const string & mreq);
+        rsm_protocol::status invoke(int &, rpc_protocol::proc_id_t proc, viewstamp vs, const string & mreq);
         rsm_protocol::status transferreq(rsm_protocol::transferres &r, const string & src,
                 viewstamp last, unsigned vid);
         rsm_protocol::status transferdonereq(int &, const string & m, unsigned vid);
@@ -54,8 +54,8 @@ class rsm : public config_view_change {
         mutex rsm_mutex, invoke_mutex;
         cond recovery_cond, sync_cond;
 
-        void execute(int procno, const string & req, string & r);
-        rsm_client_protocol::status client_invoke(string & r, int procno, const string & req);
+        void execute(rpc_protocol::proc_id_t procno, const string & req, string & r);
+        rsm_client_protocol::status client_invoke(string & r, rpc_protocol::proc_id_t procno, const string & req);
         bool statetransfer(const string & m, lock & rsm_mutex_lock);
         bool statetransferdone(const string & m, lock & rsm_mutex_lock);
         bool join(const string & m, lock & rsm_mutex_lock);
@@ -75,13 +75,12 @@ class rsm : public config_view_change {
         void recovery();
         void commit_change(unsigned vid);
 
-        template<class F, class C=void> void reg(int proc, F f, C *c=nullptr);
+        template<class P, class F, class C=void> void reg(rpc_protocol::proc_t<P> proc, F f, C *c=nullptr) {
+            static_assert(is_valid_registration<P, F>::value, "RSM handler registered with incorrect argument types");
+            reg1(proc.id, marshalled_func<F>::wrap(f, c));
+        }
 
         void start();
 };
 
-template<class F, class C> void rsm::reg(int proc, F f, C *c) {
-    reg1(proc, marshalled_func<F>::wrap(f, c));
-}
-
 #endif /* rsm_h */