++ed by:

3 PAUSE user(s)
1 non-PAUSE user(s).

Marc Lehmann


AnyEvent::MP::Kernel - the actual message passing kernel


   use AnyEvent::MP::Kernel;


This module provides most of the basic functionality of AnyEvent::MP, exposed through higher level interfaces such as AnyEvent::MP and Coro::MP.

This module is mainly of interest when knowledge about connectivity, connected nodes etc. is sought.


$AnyEvent::MP::Kernel::WARN->($level, $msg)

This value is called with an error or warning message, when e.g. a connection could not be created, authorisation failed and so on.

It must not block or send messages -queue it and use an idle watcher if you need to do any of these things.

$level should be 0 for messages to be logged always, 1 for unexpected messages and errors, 2 for warnings, 7 for messages about node connectivity and services, 8 for debugging messages and 9 for tracing messages.

The default simply logs the message to STDERR.


All code references in this array are called for every log message, from the default $WARN handler. This is an easy way to tie into the log messages without disturbing others.

$AnyEvent::MP::Kernel::WARNLEVEL [default 5 or $ENV{PERL_ANYEVENT_MP_WARNLEVEL}]

The maximum level at which warning messages will be printed to STDERR by the default warn handler.

$is_local = port_is_local $port

Returns true iff the port is a local port.

snd_to_func $node, $func, @args

Expects a node ID and a name of a function. Asynchronously tries to call this function with the given arguments on that node.

This function can be used to implement spawn-like interfaces.

snd_on $node, @msg

Executes snd with the given @msg (which must include the destination port) on the given node.

eval_on $node, $string[, @reply]

Evaluates the given string as Perl expression on the given node. When @reply is specified, then it is used to construct a reply message with "$@" and any results from the eval appended.

node_is_known $nodeid

Returns true iff the given node is currently known to the system. The only time a node is known but not up currently is when a conenction request is pending.

node_is_up $nodeid

Returns true if the given node is "up", that is, the kernel thinks it has a working connection to it.

If the node is known but not currently connected, returns 0. If the node is not known, returns undef.


Returns the node IDs of all nodes currently known to this node, including itself and nodes not currently connected.


Return the node IDs of all nodes that are currently connected (excluding the node itself).

$guard = mon_nodes $callback->($nodeid, $is_up, @reason)

Registers a callback that is called each time a node goes up (a connection is established) or down (the connection is lost).

Node up messages can only be followed by node down messages for the same node, and vice versa.

Note that monitoring a node is usually better done by monitoring it's node port. This function is mainly of interest to modules that are concerned about the network topology and low-level connection handling.

Callbacks must not block and should not send any messages.

The function returns an optional guard which can be used to unregister the monitoring callback again.

Example: make sure you call function newnode for all nodes that are up or go up (and down).

   newnode $_, 1 for up_nodes;
   mon_nodes \&newnode;




 Marc Lehmann <schmorp@schmorp.de>

Hosting generously
sponsored by Bytemark