Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
defmodule QueueAgent do
def start_link(queue, name) do
Agent.start_link(fn -> queue end, name: name)
end
def add(queue, item) do
Agent.cast(queue, fn(state) -> state ++ [item] end)
end
def get(queue) do
Agent.get_and_update(queue, fn([item | state]) -> {item, state} end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.