AnyEvent

 view release on metacpan or  search on metacpan

lib/AnyEvent/Impl/EV.pm  view on Meta::CPAN

=head1 NAME

AnyEvent::Impl::EV - AnyEvent adaptor for EV

=head1 SYNOPSIS

   use AnyEvent;
   use EV;
  
   # this module gets loaded automatically as required

=head1 DESCRIPTION

This module provides transparent support for AnyEvent. You don't have to
do anything to make EV work with AnyEvent except by loading EV before
creating the first AnyEvent watcher.

EV is the fastest event library for perl, and best supported by
AnyEvent. Most functions from the L<AE> API are implemented as direct
aliases to EV functions, so using EV via AE is as fast as using EV
directly.

=cut

package AnyEvent::Impl::EV;

use AnyEvent (); BEGIN { AnyEvent::common_sense }
use EV 4.00;

*AE::time       = \&EV::time;
*AE::now        = \&EV::now;
*AE::now_update = \&EV::now_update;
*AE::timer      = \&EV::timer;
*AE::signal     = \&EV::signal;
*AE::idle       = \&EV::idle;

# cannot override directly, as EV doesn't allow arguments
sub time       { EV::time       }
sub now        { EV::now        }
sub now_update { EV::now_update }

*AE::io = defined &EV::_ae_io # 3.8+, but keep just in case it is dropped
   ? \&EV::_ae_io
   : sub($$$) { EV::io $_[0], $_[1] ? EV::WRITE : EV::READ, $_[2] };

sub timer {
   my ($class, %arg) = @_;

   EV::timer $arg{after}, $arg{interval}, $arg{cb}
}

sub io {
   my ($class, %arg) = @_;

   EV::io
      $arg{fh},
      $arg{poll} eq "r" ? EV::READ : EV::WRITE,
      $arg{cb}
}

sub signal {
   my ($class, %arg) = @_;

   EV::signal $arg{signal}, $arg{cb}
}

sub child {
   my ($class, %arg) = @_;

   my $cb = $arg{cb};

   EV::child $arg{pid}, 0, sub {
      $cb->($_[0]->rpid, $_[0]->rstatus);
   }



( run in 2.108 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )