Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the future CPAN distribution.

Report information
The Basics
Id: 97537
Status: resolved
Priority: 0/
Queue: future

People
Owner: Nobody in particular
Requestors: TOSHIOITO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.29
Fixed in: 0.32



Subject: wait_all() etc. always returns a plain Future when no argument is given.
Download (untitled) / with headers
text/plain 409b
wait_all, wait_any, needs_all, needs_any methods correctly respect Future subclasses when some Future instances are given as arguments. However, if there is no argument, it always returns a plain Future. See the attached test script. I propose it respect the $class argument when there is no argument. So in the following case my $f = Future::Sub->wait_all(); $f should be an instance of Future::Sub.
Subject: dependent_future_subclass.t
use strict; use warnings; use Test::More; package Future::Sub; use base qw(Future); package main; foreach my $method (qw(wait_all wait_any needs_all needs_any)) { my $parent = Future::Sub->new; my $f = Future::Sub->$method($parent); isa_ok $f, "Future::Sub", "$method: non-empty arg: subclass OK"; $f = Future::Sub->$method(); isa_ok $f, "Future::Sub", "$method: empty arg: subclass OK"; } done_testing;
I wrote a patch against Future-0.31.
Subject: dependent_future_subclass.patch
diff -ru Future-0.31/lib/Future.pm Future-modified/lib/Future.pm --- Future-0.31/lib/Future.pm 2015-03-09 03:24:04.000000000 +0900 +++ Future-modified/lib/Future.pm 2015-03-09 21:31:20.828353313 +0900 @@ -1403,7 +1403,7 @@ my @subs = @_; unless( @subs ) { - my $self = Future->done; + my $self = $class->done; $self->{subs} = []; return $self; } @@ -1461,7 +1461,7 @@ my @subs = @_; unless( @subs ) { - my $self = Future->fail( "Cannot ->wait_any with no subfutures" ); + my $self = $class->fail( "Cannot ->wait_any with no subfutures" ); $self->{subs} = []; return $self; } @@ -1551,7 +1551,7 @@ my @subs = @_; unless( @subs ) { - my $self = Future->done; + my $self = $class->done; $self->{subs} = []; return $self; } @@ -1651,7 +1651,7 @@ my @subs = @_; unless( @subs ) { - my $self = Future->fail( "Cannot ->needs_any with no subfutures" ); + my $self = $class->fail( "Cannot ->needs_any with no subfutures" ); $self->{subs} = []; return $self; }
Thanks. Patch applied + unit test written. Will be in next release -- Paul Evans
Released in 0.32 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.