|
@@ -23,6 +23,10 @@ defmodule GenReset.Tracker do
|
|
|
GenServer.call(__MODULE__, :pids)
|
|
GenServer.call(__MODULE__, :pids)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ def reset do
|
|
|
|
|
+ GenServer.call(__MODULE__, :reset)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
def internal_reset do
|
|
def internal_reset do
|
|
|
GenServer.call(__MODULE__, :internal_reset)
|
|
GenServer.call(__MODULE__, :internal_reset)
|
|
|
end
|
|
end
|
|
@@ -36,11 +40,21 @@ defmodule GenReset.Tracker do
|
|
|
{:reply, :ok, state -- [pid]}
|
|
{:reply, :ok, state -- [pid]}
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ def handle_call(:reset, _from, state) do
|
|
|
|
|
+ IO.inspect(state)
|
|
|
|
|
+ for pid <- state do
|
|
|
|
|
+ IO.puts "resetting server"
|
|
|
|
|
+ IO.inspect(pid)
|
|
|
|
|
+ GenServer.call(pid, :"$gen_reset")
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def handle_call(:pids, _from, state), do: {:reply, state, state}
|
|
def handle_call(:pids, _from, state), do: {:reply, state, state}
|
|
|
|
|
|
|
|
def handle_call(:internal_reset, _from, _state), do: {:reply, :ok, []}
|
|
def handle_call(:internal_reset, _from, _state), do: {:reply, :ok, []}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
def handle_info({:DOWN, _ref, :process, object, _reason}, state) do
|
|
def handle_info({:DOWN, _ref, :process, object, _reason}, state) do
|
|
|
{:noreply, state -- [object]}
|
|
{:noreply, state -- [object]}
|
|
|
end
|
|
end
|