Clean-ups and fixes to compile with more warnings enabled and with g++.
[invirt/third/libt4.git] / paxos.cc
index b83a044..4bba25d 100644 (file)
--- a/paxos.cc
+++ b/paxos.cc
@@ -1,13 +1,15 @@
 #include "paxos.h"
 #include "handle.h"
 
+paxos_change::~paxos_change() {}
+
 bool isamember(const node_t & m, const nodes_t & nodes) {
     return find(nodes.begin(), nodes.end(), m) != nodes.end();
 }
 
 // check if l2 contains a majority of the elements of l1
-bool majority(const nodes_t &l1, const nodes_t &l2) {
-    auto overlap = (size_t)count_if(l1.begin(), l1.end(), bind(isamember, _1, l2));
+bool majority(const nodes_t & l1, const nodes_t & l2) {
+    auto overlap = (size_t)count_if(l1.begin(), l1.end(), std::bind(isamember, _1, l2));
     return overlap >= (l1.size() >> 1) + 1;
 }
 
@@ -94,7 +96,7 @@ bool proposer_acceptor::prepare(unsigned instance, nodes_t & accepts,
         if (!r)
             continue;
         auto status = (paxos_protocol::status)r->call_timeout(
-                paxos_protocol::preparereq, rpcc::to(100), res, me, instance, proposal);
+                paxos_protocol::preparereq, milliseconds(100), res, me, instance, proposal);
         if (status == paxos_protocol::OK) {
             if (res.oldinstance) {
                 LOG("commiting old instance!");
@@ -125,7 +127,7 @@ void proposer_acceptor::accept(unsigned instance, nodes_t & accepts,
             continue;
         bool accept = false;
         int status = r->call_timeout(
-                paxos_protocol::acceptreq, rpcc::to(100), accept, me, instance, proposal, v);
+                paxos_protocol::acceptreq, milliseconds(100), accept, me, instance, proposal, v);
         if (status == paxos_protocol::OK && accept)
             accepts.push_back(i);
     }
@@ -138,7 +140,7 @@ void proposer_acceptor::decide(unsigned instance, const nodes_t & accepts, const
         if (!r)
             continue;
         int res = 0;
-        r->call_timeout(paxos_protocol::decidereq, rpcc::to(100), res, me, instance, v);
+        r->call_timeout(paxos_protocol::decidereq, milliseconds(100), res, me, instance, v);
     }
 }
 
@@ -240,10 +242,10 @@ void proposer_acceptor::breakpoint2() {
 
 void proposer_acceptor::breakpoint(int b) {
     if (b == 3) {
-        LOG("Proposer: breakpoint 1");
+        LOG("breakpoint 1");
         break1 = true;
     } else if (b == 4) {
-        LOG("Proposer: breakpoint 2");
+        LOG("breakpoint 2");
         break2 = true;
     }
 }