1 | =head1 Message Passing for the Non-Blocked Mind |
1 | =head1 Message Passing for the Non-Blocked Mind |
2 | |
2 | |
3 | =head1 Introduction and Terminology |
3 | =head1 Introduction and Terminology |
4 | |
4 | |
5 | This is a tutorial about how to get the swing of the new L<AnyEvent::MP> |
5 | This is a tutorial about how to get the swing of the L<AnyEvent::MP> |
6 | module, which allows programs to transparently pass messages within the |
6 | module family, which allows processes to transparently pass messages to |
7 | process and to other processes on the same or a different host. |
7 | itself and to other processes on the same or a different host. |
8 | |
8 | |
9 | What kind of messages? Basically a message here means a list of Perl |
9 | What kind of messages? Basically a message here means a list of Perl |
10 | strings, numbers, hashes and arrays, anything that can be expressed as a |
10 | strings, numbers, hashes and arrays, anything that can be expressed as a |
11 | L<JSON> text (as JSON is the default serialiser in the protocol). Here are |
11 | L<JSON> text (as JSON is the default serialiser in the protocol). Here are |
12 | two examples: |
12 | two examples: |
… | |
… | |
17 | When using L<AnyEvent::MP> it is customary to use a descriptive string as |
17 | When using L<AnyEvent::MP> it is customary to use a descriptive string as |
18 | first element of a message that indicates the type of the message. This |
18 | first element of a message that indicates the type of the message. This |
19 | element is called a I<tag> in L<AnyEvent::MP>, as some API functions |
19 | element is called a I<tag> in L<AnyEvent::MP>, as some API functions |
20 | (C<rcv>) support matching it directly. |
20 | (C<rcv>) support matching it directly. |
21 | |
21 | |
22 | Supposedly you want to send a ping message with your current time to |
22 | Supposedly you want to send some kind of ping message with your current |
23 | somewhere, this is how such a message might look like (in Perl syntax): |
23 | time to somewhere, this is how such a message might look like (in Perl |
|
|
24 | syntax): |
24 | |
25 | |
25 | ping => 1251381636 |
26 | ping => 1251381636 |
26 | |
27 | |
27 | Now that we know what a message is, to which entities are those |
28 | Now that we know what a message is, to which entities are those |
28 | messages being I<passed>? They are I<passed> to I<ports>. A I<port> is |
29 | messages being I<passed>? They are I<passed> to I<ports>. A I<port> is |