--- AnyEvent-MP/MP/Node.pm 2009/12/30 13:37:53 1.48 +++ AnyEvent-MP/MP/Node.pm 2009/12/30 15:33:08 1.49 @@ -247,7 +247,7 @@ } sub kill { - my ($self, @args) = @_; + my (undef, @args) = @_; # we _always_ delay kil's, to avoid calling mon callbacks # from anything but the event loop context. @@ -257,26 +257,23 @@ } sub monitor { - my ($self, $portid, $cb) = @_; - - my $delay_cb = sub { - return $cb->(no_such_port => "cannot monitor nonexistent port", "$self->{id}#$portid") - unless exists $AnyEvent::MP::Kernel::PORT{$portid}; - - $AnyEvent::MP::Kernel::LMON{$portid}{$cb+0} = $cb; - }; - - $DELAY_W ? push @DELAY, $delay_cb : &$delay_cb; + # shortcut + if ($DELAY_W) { + my @args = @_; + push @DELAY, sub { AnyEvent::MP::Kernel::_monitor (@args) }; + return; + } + &AnyEvent::MP::Kernel::_monitor; } sub unmonitor { - my ($self, $portid, $cb) = @_; - - my $delay_cb = sub { - delete $AnyEvent::MP::Kernel::LMON{$portid}{$cb+0}; - }; + if ($DELAY_W) { + my @args = @_; + push @DELAY, sub { AnyEvent::MP::Kernel::_unmonitor (@args) }; + return; + } - $DELAY_W ? push @DELAY, $delay_cb : &$delay_cb; + &AnyEvent::MP::Kernel::_unmonitor; } =head1 SEE ALSO