=head1 NAME EV::AnyEvent - anyevent adaptor for EV =head1 SYNOPSIS # this module gets loaded automatically when required =head1 DESCRIPTION This module provides transparent support for AnyEvent. =cut package EV::AnyEvent; use strict; use EV; sub timer { my ($class, %arg) = @_; EV::timer $arg{after}, 0, $arg{cb} } sub io { my ($class, %arg) = @_; my $cb = $arg{cb}; EV::io $arg{fh}, ($arg{poll} =~ /r/ ? EV::READ : 0) | ($arg{poll} =~ /w/ ? EV::WRITE : 0) | EV::PERSIST, sub { $cb->( ($_[1] & EV::READ ? "r" : "") . ($_[1] & EV::WRITE ? "w" : "") ); } } sub condvar { bless \my $flag, "EV::AnyEvent" } sub broadcast { ${$_[0]}++; } sub wait { EV::loop EV::LOOP_ONCE while !${$_[0]}; } sub one_event { EV::loop EV::LOOP_ONCE; } 1; =head1 SEE ALSO L. =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ =cut