--- AnyEvent-MP/MP.pm 2009/08/16 02:55:16 1.58 +++ AnyEvent-MP/MP.pm 2009/08/24 08:04:52 1.60 @@ -128,9 +128,9 @@ our $VERSION = $AnyEvent::MP::Kernel::VERSION; our @EXPORT = qw( - NODE $NODE *SELF node_of _any_ + NODE $NODE *SELF node_of after resolve_node initialise_node - snd rcv mon kil reg psub spawn + snd rcv mon mob_guard kil reg psub spawn port ); @@ -684,6 +684,28 @@ "$noderef#$id" } +=item after $timeout, @msg + +=item after $timeout, $callback + +Either sends the given message, or call the given callback, after the +specified number of seconds. + +This is simply a utility function that come sin handy at times. + +=cut + +sub after($@) { + my ($timeout, @action) = @_; + + my $t; $t = AE::timer $timeout, 0, sub { + undef $t; + ref $action[0] + ? $action[0]() + : snd @action; + }; +} + =back =head1 AnyEvent::MP vs. Distributed Erlang