AnyEvent-MP
view release on metacpan or search on metacpan
my $list = $self->{lmon}{$portid}
or return;
@$list = grep $_ != $cb, @$list;
unless (@$list) {
$self->send (["", mon0 => $portid]);
delete $self->{monitor}{$portid};
}
}
package AnyEvent::MP::Node::Self; # the local node
use base "AnyEvent::MP::Node";
sub connect {
# we are trivially connected
}
# delay every so often to avoid recursion, also used to delay after spawn
our $DELAY = -50;
our @DELAY;
our $DELAY_W;
our $send_delayed = sub {
$AnyEvent::MP::Kernel::SRCNODE = $AnyEvent::MP::Kernel::NODE;
(shift @DELAY)->()
while @DELAY;
undef $DELAY_W;
$DELAY = -50;
};
sub transport_reset {
my ($self) = @_;
Scalar::Util::weaken $self;
$self->{send} = sub {
if (++$DELAY > 0) {
my $msg = $_[0];
push @DELAY, sub { AnyEvent::MP::Kernel::_inject (@$msg) };
$DELAY_W ||= AE::timer 0, 0, $send_delayed;
return;
}
local $AnyEvent::MP::Kernel::SRCNODE = $AnyEvent::MP::Kernel::NODE;
AnyEvent::MP::Kernel::_inject (@{ $_[0] });
};
}
sub transport_connect {
my ($self, $tp) = @_;
AE::log 9 => "I refuse to talk to myself ($tp->{peerhost}:$tp->{peerport})";
}
sub kill {
my (undef, @args) = @_;
# we _always_ delay kil's, to avoid calling mon callbacks
# from anything but the event loop context.
$DELAY = 1;
push @DELAY, sub { AnyEvent::MP::Kernel::_kill (@args) };
$DELAY_W ||= AE::timer 0, 0, $send_delayed;
}
sub monitor {
# maybe always delay, too?
if ($DELAY_W) {
my @args = @_;
push @DELAY, sub { AnyEvent::MP::Kernel::_monitor (@args) };
return;
}
&AnyEvent::MP::Kernel::_monitor;
}
sub unmonitor {
# no need to always delay
if ($DELAY_W) {
my @args = @_;
push @DELAY, sub { AnyEvent::MP::Kernel::_unmonitor (@args) };
return;
}
&AnyEvent::MP::Kernel::_unmonitor;
}
=head1 SEE ALSO
L<AnyEvent::MP>.
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
=cut
1
( run in 1.064 second using v1.01-cache-2.11-cpan-39bf76dae61 )