Explain FIFO nature of message in own example
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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"]},
|
||||||
|
|||||||
Reference in New Issue
Block a user