AnyEvent
view release on metacpan or search on metacpan
lib/AnyEvent.pm view on Meta::CPAN
$MODEL
}
for my $name (@methods) {
*$name = sub {
detect;
# we use goto because
# a) it makes the thunk more transparent
# b) it allows us to delete the thunk later
goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" }
};
}
# utility function to dup a filehandle. this is used by many backends
# to support binding more than one watcher per filehandle (they usually
# allow only one watcher per fd, so we dup it to get a different one).
sub _dupfh($$;$$) {
my ($poll, $fh, $r, $w) = @_;
# cygwin requires the fh mode to be matching, unix doesn't
lib/AnyEvent/Debug.pm view on Meta::CPAN
=cut
package AnyEvent::Debug::Wrap;
use AnyEvent (); BEGIN { AnyEvent::common_sense }
use Scalar::Util ();
use Carp ();
sub _reset {
for my $name (qw(io timer signal child idle)) {
my $super = "SUPER::$name";
*$name = sub {
my ($self, %arg) = @_;
my $w;
my $t = $TRACE;
my ($pkg, $file, $line, $sub);
lib/AnyEvent/Impl/Irssi.pm view on Meta::CPAN
my $_pidwait = sub {
my ($rpid, $rstatus) = @_;
AnyEvent::Base->_emit_childstatus ($rpid, $rstatus);
};
Irssi::signal_add pidwait => $_pidwait;
sub _emit_childstatus {
my ($self, $rpid, $rstatus) = @_;
$self->SUPER::_emit_childstatus ($rpid, $rstatus);
Irssi::signal_remove pidwait => $_pidwait;
Irssi::signal_emit pidwait => $rpid+0, $rstatus+0;
Irssi::signal_add pidwait => $_pidwait;
}
#sub loop {
# Carp::croak "Irssi does not support blocking waits";
#}
lib/AnyEvent/Impl/Qt.pm view on Meta::CPAN
=cut
package AnyEvent::Impl::Qt::Io;
use Qt;
use Qt::isa qw(Qt::SocketNotifier); # Socket? what where they smoking
use Qt::slots cb => [];
sub NEW {
my ($class, $fh, $mode, $cb) = @_;
shift->SUPER::NEW (fileno $fh, $mode);
this->{fh} = $fh;
this->{cb} = $cb;
this->connect (this, SIGNAL "activated(int)", SLOT "cb()");
}
sub cb {
this->setEnabled (0); # required according to the docs. heavy smoking required.
this->{cb}->();
this->setEnabled (1);
}
lib/AnyEvent/Impl/Qt.pm view on Meta::CPAN
use Qt;
use Qt::isa qw(Qt::Timer);
use Qt::slots cb => [];
# having to go through these contortions just to get a timer event is
# considered an advantage over other gui toolkits how?
sub NEW {
my ($class, $after, $interval, $cb) = @_;
shift->SUPER::NEW ();
this->{interval} = $interval;
this->{cb} = $cb;
this->connect (this, SIGNAL "timeout()", SLOT "cb()");
this->start ($after, 1);
}
sub cb {
this->start (this->{interval}, 1) if defined this->{interval};
this->{cb}->();
}
lib/AnyEvent/Strict.pm view on Meta::CPAN
delete $arg{poll};
confess "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
++$FD_INUSE[$fd];
bless [
$fd,
$class->SUPER::io (@_, cb => $cb)
], "AnyEvent::Strict::io";
}
sub AnyEvent::Strict::io::DESTROY {
--$FD_INUSE[$_[0][0]];
}
sub timer {
my $class = shift;
my %arg = @_;
lib/AnyEvent/Strict.pm view on Meta::CPAN
or confess "AnyEvent->timer called without mandatory 'after' parameter";
delete $arg{after};
!$arg{interval} or $arg{interval} > 0
or confess "AnyEvent->timer called with illegal interval argument '$arg{interval}'";
delete $arg{interval};
confess "AnyEvent->timer called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
$class->SUPER::timer (@_, cb => $cb)
}
sub signal {
my $class = shift;
my %arg = @_;
ref $arg{cb}
or confess "AnyEvent->signal called with illegal cb argument '$arg{cb}'";
my $cb = wrap delete $arg{cb};
defined AnyEvent::Base::sig2num $arg{signal} and $arg{signal} == 0
or confess "AnyEvent->signal called with illegal signal name '$arg{signal}'";
delete $arg{signal};
confess "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
$class->SUPER::signal (@_, cb => $cb)
}
sub child {
my $class = shift;
my %arg = @_;
ref $arg{cb}
or confess "AnyEvent->child called with illegal cb argument '$arg{cb}'";
my $cb = wrap delete $arg{cb};
$arg{pid} =~ /^-?\d+$/
or confess "AnyEvent->child called with malformed pid value '$arg{pid}'";
delete $arg{pid};
confess "AnyEvent->child called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
$class->SUPER::child (@_, cb => $cb)
}
sub idle {
my $class = shift;
my %arg = @_;
ref $arg{cb}
or confess "AnyEvent->idle called with illegal cb argument '$arg{cb}'";
my $cb = wrap delete $arg{cb};
confess "AnyEvent->idle called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
$class->SUPER::idle (@_, cb => $cb)
}
sub condvar {
my $class = shift;
my %arg = @_;
!exists $arg{cb} or ref $arg{cb}
or confess "AnyEvent->condvar called with illegal cb argument '$arg{cb}'";
my @cb = exists $arg{cb} ? (cb => wrap delete $arg{cb}) : ();
confess "AnyEvent->condvar called with unsupported parameter(s) " . join ", ", keys %arg
if keys %arg;
$class->SUPER::condvar (@cb);
}
sub time {
my $class = shift;
@_
and confess "AnyEvent->time wrongly called with paramaters";
$class->SUPER::time (@_)
}
sub now {
my $class = shift;
@_
and confess "AnyEvent->now wrongly called with paramaters";
$class->SUPER::now (@_)
}
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://anyevent.schmorp.de
=cut
1
( run in 1.196 second using v1.01-cache-2.11-cpan-49f99fa48dc )