=head1 NAME AnyEvent::MP::Global - some network-global services =head1 SYNOPSIS use AnyEvent::MP::Global; # -OR- aemp addservice AnyEvent::MP::Global:: =head1 DESCRIPTION This module provides an assortment of network-global functions: group name registration and non-local locks. It will also try to build and maintain a full mesh of all network nodes. While it isn't mandatory to run the global services, running it on one node will automatically run it on all nodes. =head1 GLOBALS AND FUNCTIONS =over 4 =cut package AnyEvent::MP::Global; use common::sense; use Carp (); use MIME::Base64 (); use AnyEvent::MP; use AnyEvent::MP::Kernel; our $VERSION = $AnyEvent::MP::VERSION; our $port = port; our %other; # our rendevouz port on the other side sub connect { my ($noderef) = @_; # monitor them, silently die mon $noderef, psub { kil $SELF }; rcv $SELF, connect_nodes => sub { connect_node $_ for @_; }; } sub mon_node { my ($noderef, $is_up) = @_; if ($is_up) { # establish connection my $other = $other{$noderef} = spawn $noderef, "AnyEvent::MP::Global::connect", $NODE; # request any other nodes possibly known to us snd $other, connect_nodes => up_nodes; } else { kil delete $other{$noderef}; } #warn "node<$noderef,$is_up>\n";#d# } mon_node $_, 1 for up_nodes; mon_nodes \&mon_node; =back =head1 SEE ALSO L. =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ =cut 1