Created
March 23, 2013 21:47
-
-
Save rfc1459/5229487 to your computer and use it in GitHub Desktop.
Stacker server example rewritten using GenX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Stacker.Server do | |
| import GenX.GenServer | |
| use GenServer.Behaviour | |
| def start_link(stack) do | |
| :gen_server.start_link({:local, Stacker.Server}, __MODULE__, stack, []) | |
| end | |
| def init(stack) do | |
| { :ok, stack } | |
| end | |
| defcall pop, export: Stacker.Server, state: [h|stack] do | |
| { :reply, h, stack } | |
| end | |
| defcast push(a), export: Stacker.Server, state: stack do | |
| { :noreply, [a|stack] } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment