--- AnyEvent-MP/MP.pm 2012/03/09 17:05:26 1.130 +++ AnyEvent-MP/MP.pm 2012/03/10 20:34:11 1.132 @@ -400,15 +400,15 @@ sub rcv($@); -sub _kilme { +my $KILME = sub { die "received message on port without callback"; -} +}; sub port(;&) { my $id = $UNIQ . ++$ID; my $port = "$NODE#$id"; - rcv $port, shift || \&_kilme; + rcv $port, shift || $KILME; $port } @@ -896,11 +896,16 @@ =head1 DISTRIBUTED DATABASE AnyEvent::MP comes with a simple distributed database. The database will -be mirrored asynchronously at all global nodes. Other nodes bind to one of -the global nodes for their needs. +be mirrored asynchronously on all global nodes. Other nodes bind to one +of the global nodes for their needs. Every node has a "local database" +which contains all the values that are set locally. All local databases +are merged together to form the global database, which can be queried. + +The database structure is that of a two-level hash - the database hash +contains hashes which contain values, similarly to a perl hash of hashes, +i.e.: -The database consists of a two-level hash - a hash contains a hash which -contains values. + $DATABASE{$family}{$subkey} = $value The top level hash key is called "family", and the second-level hash key is called "subkey" or simply "key". @@ -915,7 +920,7 @@ The subkeys must be non-empty strings, with no further restrictions. The values should preferably be strings, but other perl scalars should -work as well (such as undef, arrays and hashes). +work as well (such as C, arrays and hashes). Every database entry is owned by one node - adding the same family/subkey combination on multiple nodes will not cause discomfort for AnyEvent::MP, @@ -988,6 +993,9 @@ respectively. If no keys have changed then the array reference might be C or even missing. +If not called in void context, a guard object is returned that, when +destroyed, stops the monitor. + The family hash reference and the key arrays belong to AnyEvent::MP and B by the callback. When in doubt, make a copy.