Muz*_*hua 4 erlang message-passing
当您向shell进程发送消息时,可以通过调用以下命令清除所有消息: c:flush().
C:\Windows\System32>erl Eshell V5.9 (abort with ^G) 1> self() ! josh. josh 2> self() ! me. me 3> self() ! you. you 4> flush(). Shell got josh Shell got me Shell got you ok 5>
在我的想法中,这会清空shell进程的邮箱.清空任何erlang进程邮箱的等效方法是什么?
此函数应刷新邮箱中的所有邮件(在您调用它的任何进程中):
flush() ->
receive
_ -> flush()
after
0 -> ok
end.
Run Code Online (Sandbox Code Playgroud)