I’m writing my bachelor’s thesis on visualizing distributed protocols using Elixir, and I’ve run into the problem that the built-in Kino render_seq_trace function doesn’t display the messages in their actual order. Does anyone know how to fix this? I only learned Elixir two months ago and need a practical solution quickly.
defmodule Test do
def func() do
receive do
{:message, pid} ->
send(pid, {:back, self()})
receive do
{:back, _pid} -> :ok
end
end
end
def execute() do
p1 = spawn(fn -> func() end)
p2 = spawn(fn -> func() end)
send(p1, {:message, p2})
send(p2, {:message, p1})
receive do
_ -> :ok
after
100 -> :timeout
end
end
end
Kino.Process.render_seq_trace(fn -> Test.execute() end)
I know the receive in the end is not doing anything but without the :back messages are not being displayed at all. That’s another weird phenomenon. Every time I run this code I get a different order in the diagram.
I can’t upload images but e.g. the messages are shown before the SPAWN.