Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
defmodule Queue do
use GenServer
def start_link(queue, name) do
GenServer.start(__MODULE__, queue, name: name)
end
# GenServer callbacks
def handle_call(:get, _from, [item | queue]) do
{:reply, item, queue}
end
def handle_cast({:add, item}, queue) do
{:noreply, queue ++ [item]}
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.