Marc Lehmann > AnyEvent-MP-1.30 > AnyEvent::MP::Global

Download:
AnyEvent-MP-1.30.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

AnyEvent::MP::Global - some network-global services

SYNOPSIS ^

   use AnyEvent::MP::Global;

DESCRIPTION ^

This module maintains a fully-meshed network, if possible, and tries to ensure that we are connected to at least one other node.

It also manages named port groups - ports can register themselves in any number of groups that will be available network-wide, which is great for discovering services.

Running it on one node will automatically run it on all nodes, although, at the moment, the global service is started by default anyways.

GLOBALS AND FUNCTIONS ^

$guard = grp_reg $group, $port

Register the given (local!) port in the named global group $group.

The port will be unregistered automatically when the port is destroyed.

When not called in void context, then a guard object will be returned that will also cause the name to be unregistered when destroyed.

$ports = grp_get $group

Returns all the ports currently registered to the given group (as read-only(!) array reference). When the group has no registered members, return undef.

$guard = grp_mon $group, $callback->($ports, $add, $del)

Installs a monitor on the given group. Each time there is a change it will be called with the current group members as an arrayref as the first argument. The second argument only contains ports added, the third argument only ports removed.

Unlike grp_get, all three arguments will always be array-refs, even if the array is empty. None of the arrays must be modified in any way.

The first invocation will be with the first two arguments set to the current members, as if all of them were just added, but only when the group is actually non-empty.

Optionally returns a guard object that uninstalls the watcher when it is destroyed.

SEE ALSO ^

AnyEvent::MP.

AUTHOR ^

 Marc Lehmann <schmorp@schmorp.de>
 http://home.schmorp.de/
syntax highlighting: