Added by attached patch.
--
Paul Evans
=== modified file 'lib/IO/Async/Notifier.pm'
--- lib/IO/Async/Notifier.pm 2018-04-02 18:43:40 +0000
+++ lib/IO/Async/Notifier.pm 2019-06-12 15:41:02 +0000
@@ -359,6 +359,24 @@
return $f;
}
+=head2 adopted_futures
+
+ @f = $notifier->adopted_futures
+
+I<Since version 0.73.>
+
+Returns a list of all the adopted and still-pending futures, in no particular
+order.
+
+=cut
+
+sub adopted_futures
+{
+ my $self = shift;
+
+ return values %{ $self->{IO_Async_Notifier__futures} };
+}
+
=head1 CHILD NOTIFIERS
During the execution of a program, it may be the case that certain IO handles
=== modified file 't/07notifier-future.t'
--- t/07notifier-future.t 2014-07-11 13:48:36 +0000
+++ t/07notifier-future.t 2019-06-12 15:41:02 +0000
@@ -21,14 +21,22 @@
{
my $f = Future->new;
+ is_deeply( [ $notifier->adopted_futures ], [],
+ '->adopted_futures initially' );
+
$notifier->adopt_future( $f );
is_refcount( $f, 2, '$f has refcount 2 after ->adopt_future' );
is_oneref( $notifier, '$notifier still has refcount 1 after ->adopt_future' );
+ is_deeply( [ $notifier->adopted_futures ], [ $f ],
+ '->adopted_futures after adoption' );
$f->done( "result" );
is_refcount( $f, 1, '$f has refcount 1 after $f->done' );
+
+ is_deeply( [ $notifier->adopted_futures ], [],
+ '->adopted_futures finally' );
}
# fail