2008-11-12 3 views
5

In Erlang hat jeder Prozess einen Gruppenleiter, und wenn ein Prozess etwas drucken möchte (d. H. Er ruft die io-Bibliothek auf oder macht etwas ähnliches), sendet er eine Nachricht an seinen Gruppenleiter.Gibt es eine Spezifikation des Gruppenleiterprotokolls, das IO verarbeitet?

Meine Frage ist, wo kann ich die Spezifikation dieser Nachrichten finden? Oder allgemein gesagt, was sollte ein Gruppenleiter tun?

Ich habe mit etwas experimentieren herausgefunden, dass manchmal der Prozess einen {io_request, Sender, GroupLeader, Request} Begriff sendet, und die Antwort ist ein {io_reply, GroupLeader, ok} Begriff, aber es kann andere Fälle geben.

Antwort

6

The Erlang Rationale (video) oder (slides); ist eine gute Informationsquelle, ebenso wie der Quellcode für user.erl.

Kurz:

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

Einige Anforderungen 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) 
Verwandte Themen