Cosmetic improvements.
[invirt/third/libt4.git] / config.h
index 074cbe9..895de1b 100644 (file)
--- a/config.h
+++ b/config.h
@@ -1,23 +1,8 @@
 #ifndef config_h
 #define config_h
 
-#include <string>
-#include <vector>
+#include "types.h"
 #include "paxos.h"
-#include "lock.h"
-
-using std::chrono::steady_clock;
-using std::chrono::seconds;
-using std::string;
-using std::vector;
-using std::thread;
-using std::ostringstream;
-using std::istringstream;
-using std::ostream_iterator;
-using std::istream_iterator;
-using std::copy;
-using std::min;
-using std::min_element;
 
 class config_view_change {
     public:
@@ -31,37 +16,33 @@ class config : public paxos_change {
         string first;
         string me;
         config_view_change *vc;
-        acceptor paxos_acceptor;
-        proposer paxos_proposer;
+        proposer_acceptor paxos;
         vector<string> mems;
         mutex cfg_mutex;
         cond config_cond;
-        paxos_protocol::status heartbeat(int &r, string m, unsigned instance);
-        string value(const vector<string> &mems) const;
-        vector<string> members(const string &v) const;
-        void get_view(unsigned instance, vector<string> &m, lock &cfg_mutex_lock);
-        bool remove(const string &, lock &cfg_mutex_lock);
-        void reconstruct(lock &cfg_mutex_lock);
+        paxos_protocol::status heartbeat(int & r, string m, unsigned instance);
+        void get_view(unsigned instance, vector<string> & m, lock & cfg_mutex_lock);
+        bool remove(const string &, lock & cfg_mutex_lock);
+        void reconstruct(lock & cfg_mutex_lock);
         typedef enum {
-            OK,        // response and same view #
-            VIEWERR,   // response but different view #
-            FAILURE,   // no response
+            OK, // response and same view #
+            VIEWERR, // response but different view #
+            FAILURE, // no response
         } heartbeat_t;
-        heartbeat_t doheartbeat(const string &m, lock &cfg_mutex_lock);
+        heartbeat_t doheartbeat(const string & m, lock & cfg_mutex_lock);
     public:
-        config(const string &_first, const string &_me, config_view_change *_vc);
+        config(const string & _first, const string & _me, config_view_change *_vc);
         unsigned view_id() { return my_view_id; }
-        const string &myaddr() const { return me; }
-        string dump() { return paxos_acceptor.dump(); }
-        void get_view(unsigned instance, vector<string> &m);
-        void restore(const string &s);
+        const string & myaddr() const { return me; }
+        string dump() { return paxos.dump(); }
+        void get_view(unsigned instance, vector<string> & m);
+        void restore(const string & s);
         bool add(const string &, unsigned view_id);
-        bool ismember(const string &m, unsigned view_id);
-        void heartbeater(void);
-        void paxos_commit(unsigned instance, const string &v);
-        // XXX hack; maybe should have its own port number
-        rpcs *get_rpcs() { return paxos_acceptor.get_rpcs(); }
-        void breakpoint(int b) { paxos_proposer.breakpoint(b); }
+        bool ismember(const string & m, unsigned view_id);
+        void heartbeater NORETURN ();
+        void paxos_commit(unsigned instance, const string & v);
+        rpcs *get_rpcs() { return paxos.get_rpcs(); }
+        void breakpoint(int b) { paxos.breakpoint(b); }
 };
 
 #endif