ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Intro.pod
(Generate patch)

Comparing AnyEvent-MP/MP/Intro.pod (file contents):
Revision 1.44 by root, Tue Feb 28 18:37:24 2012 UTC vs.
Revision 1.45 by root, Sun Mar 4 15:12:26 2012 UTC

211the sender and one for the receiver. First the receiver application, in 211the sender and one for the receiver. First the receiver application, in
212full: 212full:
213 213
214 use AnyEvent; 214 use AnyEvent;
215 use AnyEvent::MP; 215 use AnyEvent::MP;
216 use AnyEvent::MP::Global;
217 216
218 configure nodeid => "eg_receiver", binds => ["*:4040"]; 217 configure nodeid => "eg_receiver/%u", binds => ["*:4040"];
219 218
220 my $port = port; 219 my $port = port;
221
222 grp_reg eg_receivers => $port; 220 my $db_guard = db_reg eg_receivers => $port;
223 221
224 rcv $port, test => sub { 222 rcv $port, test => sub {
225 my ($data, $reply_port) = @_; 223 my ($data, $reply_port) = @_;
226 224
227 print "Received data: " . $data . "\n"; 225 print "Received data: " . $data . "\n";
356talking about the receiver. 354talking about the receiver.
357 355
358Let's look at the next line(s): 356Let's look at the next line(s):
359 357
360 my $port = port; 358 my $port = port;
361 grp_reg eg_receivers => $port; 359 my $db_guard = db_reg eg_receivers => $port;
362 360
363The C<port> function has already been discussed. It simply creates a new 361The C<port> function has already been discussed. It simply creates a new
364I<port> and returns the I<port ID>. The C<grp_reg> function, however, is 362I<port> and returns the I<port ID>. The C<grp_reg> function, however, is
365new: The first argument is the name of a I<global group>, and the second 363new: The first argument is the name of a I<global group>, and the second
366argument is the I<port ID> to register in that group. 364argument is the I<port ID> to register in that group.
384 382
385Ok, now let's take a look at the sender code: 383Ok, now let's take a look at the sender code:
386 384
387 use AnyEvent; 385 use AnyEvent;
388 use AnyEvent::MP; 386 use AnyEvent::MP;
389 use AnyEvent::MP::Global;
390 387
391 configure nodeid => "eg_sender", seeds => ["*:4040"]; 388 configure nodeid => "eg_sender/%u", seeds => ["*:4040"];
392 389
393 my $find_timer = 390 my $find_timer =
394 AnyEvent->timer (after => 0, interval => 1, cb => sub { 391 AnyEvent->timer (after => 0, interval => 1, cb => sub {
395 my $ports = grp_get "eg_receivers" 392 my $ports = grp_get "eg_receivers"
396 or return; 393 or return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines