Skip to content

Instantly share code, notes, and snippets.

@mdaisuke
Created November 29, 2015 11:53
Show Gist options
  • Save mdaisuke/3e4a19cb4f13374eac97 to your computer and use it in GitHub Desktop.
Save mdaisuke/3e4a19cb4f13374eac97 to your computer and use it in GitHub Desktop.
defmodule TmpMo do
def start_link do
Task.start_link(fn -> loop(%{}) end)
end
defp loop(map) do
receive do
{:get, key, caller} ->
send caller, Map.get(map, key)
{:put, key, value} ->
loop(Map.put(map, key, value))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment