Manually manage process rather than relying on linking

This prevents the race condition that was causing issues between koans
as each is run in its own process.
This commit is contained in:
Jay Hayes
2022-02-10 07:57:49 -06:00
parent 11601a6945
commit b598df498e

View File

@@ -12,9 +12,13 @@ defmodule GenServers do
{:ok, args} {:ok, args}
end end
def start_link(init_password) do def start(init_password) do
# The __MODULE__ macro returns the current module name as an atom # The __MODULE__ macro returns the current module name as an atom
GenServer.start_link(__MODULE__, init_password, name: __MODULE__) GenServer.start(__MODULE__, init_password, name: __MODULE__)
end
def stop do
GenServer.stop(__MODULE__)
end end
def unlock(password) do def unlock(password) do
@@ -151,5 +155,7 @@ defmodule GenServers do
{_, response} = Laptop.owner_name() {_, response} = Laptop.owner_name()
assert response == ___ assert response == ___
:ok = Laptop.stop()
end end
end end