… | |
… | |
23 | snd $port, type => data...; |
23 | snd $port, type => data...; |
24 | snd $port, @msg; |
24 | snd $port, @msg; |
25 | snd @msg_with_first_element_being_a_port; |
25 | snd @msg_with_first_element_being_a_port; |
26 | |
26 | |
27 | # creating/using ports, the simple way |
27 | # creating/using ports, the simple way |
28 | my $somple_port = port { my @msg = @_; 0 }; |
28 | my $simple_port = port { my @msg = @_; 0 }; |
29 | |
29 | |
30 | # creating/using ports, tagged message matching |
30 | # creating/using ports, tagged message matching |
31 | my $port = port; |
31 | my $port = port; |
32 | rcv $port, ping => sub { snd $_[0], "pong"; 0 }; |
32 | rcv $port, ping => sub { snd $_[0], "pong"; 0 }; |
33 | rcv $port, pong => sub { warn "pong received\n"; 0 }; |
33 | rcv $port, pong => sub { warn "pong received\n"; 0 }; |
… | |
… | |
69 | |
69 | |
70 | =item port |
70 | =item port |
71 | |
71 | |
72 | A port is something you can send messages to (with the C<snd> function). |
72 | A port is something you can send messages to (with the C<snd> function). |
73 | |
73 | |
74 | Some ports allow you to register C<rcv> handlers that can match specific |
74 | Ports allow you to register C<rcv> handlers that can match all or just |
75 | messages. All C<rcv> handlers will receive messages they match, messages |
75 | some messages. Messages will not be queued. |
76 | will not be queued. |
|
|
77 | |
76 | |
78 | =item port id - C<noderef#portname> |
77 | =item port id - C<noderef#portname> |
79 | |
78 | |
80 | A port id is normaly the concatenation of a noderef, a hash-mark (C<#>) as |
79 | A port ID is the concatenation of a noderef, a hash-mark (C<#>) as |
81 | separator, and a port name (a printable string of unspecified format). An |
80 | separator, and a port name (a printable string of unspecified format). An |
82 | exception is the the node port, whose ID is identical to its node |
81 | exception is the the node port, whose ID is identical to its node |
83 | reference. |
82 | reference. |
84 | |
83 | |
85 | =item node |
84 | =item node |
86 | |
85 | |
87 | A node is a single process containing at least one port - the node |
86 | A node is a single process containing at least one port - the node port, |
88 | port. You can send messages to node ports to find existing ports or to |
87 | which provides nodes to manage each other remotely, and to create new |
89 | create new ports, among other things. |
88 | ports. |
90 | |
89 | |
91 | Nodes are either private (single-process only), slaves (connected to a |
90 | Nodes are either private (single-process only), slaves (connected to a |
92 | master node only) or public nodes (connectable from unrelated nodes). |
91 | master node only) or public nodes (connectable from unrelated nodes). |
93 | |
92 | |
94 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |
93 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |