有处理IO的组长协议的规范吗? [英] Is there a specification of the group leader protocol that handles IO?

查看:77
本文介绍了有处理IO的组长协议的规范吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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



我设法找出一些实验,有时该进程发送一个 { io_request,Sender,GroupLeader,Request} 术语,答案是 {io_reply,GroupLeader,ok} 术语,但可能还有其他情况。

解决方案

Erlang理由(视频) (幻灯片);是一个很好的信息来源,以及 user.erl



简而言之:

 code> {io_request,From,ReplyAs,Request} 
%From是发送回复的过程,
%ReplyAs是呼叫者期望的任何条款
%匹配请求和响应。 (回复中逐字回复)
{io_reply,ReplyAs,Reply}

user.erl:

  {put_chars,IoList}%将iolist 
{put_chars,M,F,A} %表示apply(M,F,A)
{get_geometry,'rows'|的结果'columns'}%返回控制台的行或列数
{get_line,Prompt}%调用io_lib:collect_line(Prompt)
{get_chars,Prompt,Mod,Func,ExtraArgs}
{get_until,Prompt,Mod,Func,Args}
{setopts,选项}用户支持的%only选项是'binary'
%(如果存在于选项中,则为二进制模式,否则为列表模式)


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.

解决方案

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)

这篇关于有处理IO的组长协议的规范吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆