在Erlang中,每个进程都有一个组长,当进程想要打印某些东西时(即它调用io库或做类似的事情),它会向其组长发送一条消息.
我的问题是,我在哪里可以找到这些消息的规范?或者一般来说,组长应该做什么的说明?
我设法通过一些实验发现,有时候过程发送一个{io_request, Sender, GroupLeader, Request}术语,答案是一个{io_reply, GroupLeader, ok}术语,但可能还有其他案例.
Erlang Rationale(视频)或(幻灯片) ; 是一个很好的信息来源,user.erl的源代码也是如此.
简而言之:
{io_request, From, ReplyAs, Request}
%From is the process to send the reply to,
%ReplyAs is any term the caller desires to
%match up the request and the response. (returned verbatim in the reply)
{io_reply, ReplyAs, Reply}
Run Code Online (Sandbox Code Playgroud)
user.erl中的一些请求:
{put_chars, IoList} % puts the iolist
{put_chars, M,F,A} % puts the result of apply(M,F,A)
{get_geometry, 'rows' | 'columns'} % returns the number of rows or columns of the console
{get_line, Prompt} % calls io_lib:collect_line(Prompt)
{get_chars, Prompt, Mod, Func, ExtraArgs}
{get_until, Prompt, Mod, Func, Args}
{setopts, Options} % only option supported by user is 'binary'
% (binary mode if present in Options, list mode otherwise)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
665 次 |
| 最近记录: |