AnyEvent-ForkObject
view release on metacpan or search on metacpan
my $timer = AE::timer 0.01, 0.01 => sub {
return if $phase < 5;
undef $obj; $cv->send
};
my $timeout; $timeout =
AE::timer 2, 0 => sub { undef $obj; undef $timeout; $cv->send };
$cv->recv;
ok $timeout, "Timeout wasn't reached";
}
{
my $cv = condvar AnyEvent;
my $obj = new AnyEvent::ForkObject;
ok $obj, "Constructor";
$obj->do(require => 'Data::Dumper', cb => sub {
diag explain \@_ unless ok $_[0] eq 'ok', 'require Data::Dumper';
$dont_call_if_destroyed = 0;
});
kill KILL => $obj2->{pid};
undef $obj2;
my $timeout; $timeout = AE::timer 1, 0 => sub { undef $timeout; $cv->send };
$cv->recv;
ok $dont_call_if_destroyed, "Don't touch callbacks if destroyed";
ok $timeout, "Timeout wasn't reached";
}
package FO_Test;
sub new
{
bless { val => $_[1] } => __PACKAGE__;
}
( run in 0.391 second using v1.01-cache-2.11-cpan-a5abf4f5562 )