Skip to content

Commit

Permalink
Define Consumer module which periodically asks for new item from prod…
Browse files Browse the repository at this point in the history
…ucer then prints it
  • Loading branch information
alimoezzi committed Feb 13, 2021
1 parent 05061e9 commit f5b0e76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/procon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ defmodule Procon.Producer do
{:noreply, state ++ Enum.to_list(50..(2 * 50 + 1))}
end
end

defmodule Procon.Consumer do
def start do
spawn(loop())
end

def loop do
IO.puts("Consumer #{inspect(self())} consumes #{Procon.Producer.get()}")
Process.sleep(1000)
loop()
end
end

0 comments on commit f5b0e76

Please sign in to comment.