App-mirai
view release on metacpan or search on metacpan
lib/App/mirai/Future.pm view on Meta::CPAN
$_->invoke_event(label => $f) for grep defined, @WATCHERS;
return $f;
}
}
BEGIN {
my $prep = sub {
my $f = shift;
# Grab the stacktrace first, so we know who started this
my (undef, $file, $line) = caller(1);
my $stack = do {
my @stack;
my $idx = 1;
while(my @x = caller($idx++)) {
unshift @stack, [ @x[0, 1, 2] ];
}
\@stack
};
# I don't know why this is here.
if(exists $FUTURE_MAP{$f}) {
$FUTURE_MAP{$f}{type} = (exists $f->{subs} ? 'dependent' : 'leaf');
return $f;
}
lib/App/mirai/Future.pm view on Meta::CPAN
Scalar::Util::weaken($entry->{future});
my $name = "$f";
$FUTURE_MAP{$name} = $entry;
# Yes, this means we're modifying the callback list: if we later
# add support for debugging the callbacks as well, we'd need to
# take this into account.
$f->on_ready(sub {
my $f = shift;
my (undef, $file, $line) = caller(2);
$FUTURE_MAP{$f}->{status} =
$f->{failure}
? "failed"
: $f->{cancelled}
? "cancelled"
: "done";
$FUTURE_MAP{$f}->{ready_at} = "$file:$line";
$FUTURE_MAP{$f}->{ready_stack} = do {
my @stack;
my $idx = 1;
while(my @x = caller($idx++)) {
unshift @stack, [ @x[0,1,2] ];
}
\@stack
};
# who's in charge of picking names around here? do we not have
# any interest in consistency?
$_->invoke_event(on_ready => $f) for grep defined, @WATCHERS;
});
};
( run in 0.232 second using v1.01-cache-2.11-cpan-cc502c75498 )