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

Comparing AnyEvent-MP/MP/Global.pm (file contents):
Revision 1.34 by root, Thu Nov 5 01:12:41 2009 UTC vs.
Revision 1.35 by root, Sat Nov 7 02:36:31 2009 UTC

43 grp_get 43 grp_get
44 grp_mon 44 grp_mon
45); 45);
46 46
47our $GLOBAL_VERSION = 0; 47our $GLOBAL_VERSION = 0;
48
49our %ON_SETUP; # take note: not public
48 50
49our %addr; # port ID => [address...] mapping 51our %addr; # port ID => [address...] mapping
50 52
51our %port; # our rendezvous port on the other side 53our %port; # our rendezvous port on the other side
52our %lreg; # local registry, name => [pid...] 54our %lreg; # local registry, name => [pid...]
303 }; 305 };
304 306
305 snd $port, addr => $AnyEvent::MP::Kernel::LISTENER; 307 snd $port, addr => $AnyEvent::MP::Kernel::LISTENER;
306 snd $port, nodes => \%addr if %addr; 308 snd $port, nodes => \%addr if %addr;
307 snd $port, set => \%lreg if %lreg; 309 snd $port, set => \%lreg if %lreg;
310 snd $port, "setup"; # tell the other side that we are in business now
308} 311}
309 312
310# other nodes connect via this 313# other nodes connect via this
311sub connect { 314sub connect {
312 my ($version, $node) = @_; 315 my ($version, $node) = @_;
319 delete $SEEDME{$node}; 322 delete $SEEDME{$node};
320 kil $SELF; 323 kil $SELF;
321 }; 324 };
322 325
323 rcv $SELF, 326 rcv $SELF,
327 setup => sub {
328 $_->($node) for values %ON_SETUP;
329 },
324 addr => sub { 330 addr => sub {
325 my $addresses = shift; 331 my $addresses = shift;
326 $AnyEvent::MP::Kernel::WARN->(9, "$node told us its addresses (@$addresses)."); 332 $AnyEvent::MP::Kernel::WARN->(9, "$node told us its addresses (@$addresses).");
327 $addr{$node} = $addresses; 333 $addr{$node} = $addresses;
328 334
341 my $node = AnyEvent::MP::Kernel::add_node $id; 347 my $node = AnyEvent::MP::Kernel::add_node $id;
342 $node->connect (@$addresses); 348 $node->connect (@$addresses);
343 start_node $id; 349 start_node $id;
344 } 350 }
345 }, 351 },
352 set => sub {
353 set_groups $node, shift;
354 },
346 find => sub { 355 find => sub {
347 my ($othernode) = @_; 356 my ($othernode) = @_;
348 357
349 $AnyEvent::MP::Kernel::WARN->(9, "$node asked us to find $othernode."); 358 $AnyEvent::MP::Kernel::WARN->(9, "$node asked us to find $othernode.");
350 snd $port{$node}, nodes => { $othernode => $addr{$othernode} } 359 snd $port{$node}, nodes => { $othernode => $addr{$othernode} }
351 if $addr{$othernode}; 360 if $addr{$othernode};
352 },
353 set => sub {
354 set_groups $node, shift;
355 }, 361 },
356 reg0 => sub { 362 reg0 => sub {
357 _change $_[0], [], [$_[1]]; 363 _change $_[0], [], [$_[1]];
358 }, 364 },
359 reg1 => sub { 365 reg1 => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines