是否有处理 IO 的组长协议规范?

发布于 2024-07-08 22:47:57 字数 277 浏览 6 评论 0原文

在Erlang中,每个进程都有一个组长,当一个进程想要打印一些东西(即它调用io库或做类似的事情)时,它会向其组长发送一条消息。

我的问题是,在哪里可以找到这些消息的规范? 或者一般来说,明确小组领导者应该做什么?

我通过一些实验发现,有时进程会发送一个 {io_request, Sender, GroupLeader, Request} 术语,而答案是一个 {io_reply, GroupLeader, ok} 术语,但可能还有其他情况。

In Erlang, every process has a group leader, and when a process wants to print something (i.e. it calls the io library or does something similar), it will send a message to its group leader.

My question is, where can I find the specification of these messages? Or in general, the specification of what a group leader should do?

I managed to find out with some experimenting that sometimes the process sends an {io_request, Sender, GroupLeader, Request} term, and the answer is an {io_reply, GroupLeader, ok} term, but there may be other cases.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自此以后,行同陌路 2024-07-15 22:47:57

Erlang 原理(视频)(幻灯片); 是一个很好的信息来源,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}

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)

The Erlang Rationale (video) or (slides); is a good source of information, as is the source code for user.erl.

In short:

  {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}

Some requests in 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)
心的憧憬 2024-07-15 22:47:57

Erlang I/O 协议详细描述如下:

http://www.erlang .org/doc/apps/stdlib/io_protocol.html

The Erlang I/O protocol is described in detail here:

http://www.erlang.org/doc/apps/stdlib/io_protocol.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文