… | |
… | |
21 | snd $port, type => data...; |
21 | snd $port, type => data...; |
22 | snd $port, @msg; |
22 | snd $port, @msg; |
23 | snd @msg_with_first_element_being_a_port; |
23 | snd @msg_with_first_element_being_a_port; |
24 | |
24 | |
25 | # creating/using ports, the simple way |
25 | # creating/using ports, the simple way |
26 | my $simple_port = port { my @msg = @_; 0 }; |
26 | my $simple_port = port { my @msg = @_ }; |
27 | |
27 | |
28 | # creating/using ports, tagged message matching |
28 | # creating/using ports, tagged message matching |
29 | my $port = port; |
29 | my $port = port; |
30 | rcv $port, ping => sub { snd $_[0], "pong"; 0 }; |
30 | rcv $port, ping => sub { snd $_[0], "pong" }; |
31 | rcv $port, pong => sub { warn "pong received\n"; 0 }; |
31 | rcv $port, pong => sub { warn "pong received\n" }; |
32 | |
32 | |
33 | # create a port on another node |
33 | # create a port on another node |
34 | my $port = spawn $node, $initfunc, @initdata; |
34 | my $port = spawn $node, $initfunc, @initdata; |
35 | |
35 | |
36 | # monitoring |
36 | # monitoring |