Created
July 3, 2018 13:12
-
-
Save enpedasi/f9794d79a12df0332a22d16b17411cbe to your computer and use it in GitHub Desktop.
NIF Thread Reciever (GenServer)
This file contains 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 NIFThread.Receiver do | |
use GenServer | |
def start_link(init_list\\[]) do | |
GenServer.start_link(__MODULE__, init_list) | |
end | |
def init(list) do | |
{:ok, list} | |
end | |
def handle_call(:get, _from, state) do | |
{:reply, state, []} | |
end | |
def handle_info({:push, new_state}, state) do | |
# IO.inspect server: new_state | |
{:noreply, [new_state | state]} | |
end | |
def handle_info(:ok, state) do | |
{:noreply, state} | |
end | |
def handle_info({:ok, _new_state}, state) do | |
{:noreply, state} | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment