Explain FIFO nature of message in own example

This commit is contained in:
Jay Hayes
2016-05-04 15:17:52 -05:00
parent 75c54e0585
commit 6aae32e672
2 changed files with 10 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ defmodule Processes do
assert Process.alive?(pid) == ___ assert Process.alive?(pid) == ___
end end
koan "Processes can send and receive messages; it's like a mailbox!" do koan "Processes can send and receive messages" do
send self, "hola!" send self, "hola!"
receive do receive do
@@ -36,6 +36,14 @@ defmodule Processes do
end end
end end
koan "Received messages are queued, first in first out" do
send self, "hola!"
send self, "como se llama?"
assert_receive ___
assert_receive ___
end
koan "A common pattern is to include the sender in the message, so that it can reply" do koan "A common pattern is to include the sender in the message, so that it can reply" do
greeter = fn -> greeter = fn ->
receive do receive do

View File

@@ -10,6 +10,7 @@ defmodule ProcessesTests do
true, true,
true, true,
"hola!", "hola!",
{:multiple, ["hola!", "como se llama?"]},
:how_are_you?, :how_are_you?,
{:multiple, ["O", "HAI"]}, {:multiple, ["O", "HAI"]},
{:multiple, ["foo", "bar"]}, {:multiple, ["foo", "bar"]},