Compare commits

..

No commits in common. "f2c4e10542aee179cfd45d8b0040cd05128516ad" and "e3971d2ff6552e63294503ef3b26ed553c98ec29" have entirely different histories.

View File

@ -455,13 +455,25 @@ defmodule Paxos do
def propose_loop(inInst) do def propose_loop(inInst) do
receive do receive do
{:timeout, inst} -> {:timeout, inst} ->
check_and_apply({:timeout}, inst, inInst, &propose_loop/1) if inInst == inst do
{:timeout}
else
propose_loop(inInst)
end
{:abort, inst} -> {:abort, inst} ->
check_and_apply({:abort}, inst, inInst, &propose_loop/1) if inInst == inst do
{:abort}
else
propose_loop(inInst)
end
{:decision, inst, d} -> {:decision, inst, d} ->
check_and_apply({:decision, d}, inst, inInst, &propose_loop/1) if inInst == inst do
{:decision, d}
else
propose_loop(inInst)
end
x -> x ->
Process.send_after(self(), x, 500) Process.send_after(self(), x, 500)
@ -477,22 +489,22 @@ defmodule Paxos do
def get_decision_loop(inInst) do def get_decision_loop(inInst) do
receive do receive do
{:get_value_res, inst} -> {:get_value_res, inst} ->
check_and_apply(nil, inst, inInst, &get_decision_loop/1) if inst == inInst do
nil
else
get_decision_loop(inInst)
end
{:get_value_res_actual, inst, v} -> {:get_value_res_actual, inst, v} ->
check_and_apply(v, inst, inInst, &get_decision_loop/1) if inst == inInst do
v
else
get_decision_loop(inInst)
end
x -> x ->
Process.send_after(self(), x, 500) Process.send_after(self(), x, 500)
get_decision_loop(inInst) get_decision_loop(inInst)
end end
end end
def check_and_apply(v, inst, inInst, fun) do
if inst == inInst do
v
else
fun.(inInst)
end
end
end end