gpt4 book ai didi

erlang - Erlang 中的空进程邮箱

转载 作者:行者123 更新时间:2023-12-04 23:26:34 26 4
gpt4 key购买 nike

当你向 shell 进程发送消息时,你可以通过调用: c:flush(). 来清除所有消息。 C:\Windows\System32>erl
Eshell V5.9(使用 ^G 中止)
1> 自我()!乔希。
乔希
2> 自我()!我。

3> 自我()!你。

4> 冲洗()。
shell 牌得到了乔希
shell 牌让我
shell 牌有你
好的
5>

在我看来,这会清空 shell 进程的邮箱。
清空任何 erlang 进程的邮箱的等效方法是什么?

最佳答案

此函数应刷新邮箱中的所有消息(在您调用它的任何进程中):

flush() ->
receive
_ -> flush()
after
0 -> ok
end.

关于erlang - Erlang 中的空进程邮箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11989627/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com