Skip Menu |

This queue is for tickets about the future CPAN distribution.

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

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

Bug Information
Severity: (no value)
Broken in: 0.34
Fixed in: 0.35



Subject: fmap ->cancel with undef slots
In some situations, the fmap slots can be undef when ->cancel is called. ->fail and other states are handled correctly, looks like this one is just an oversight.
Subject: 2017-02-07-fmap-cancel.patch
commit f0f38344839c4c4fe6dbde039592b19cab7189ab Author: Tom Molesworth <TEAM@cpan.org> Date: Mon Feb 6 23:34:42 2017 +0800 ->cancel checks for undef slots diff --git a/lib/Future/Utils.pm b/lib/Future/Utils.pm index c8cf3cb..1e62565 100644 --- a/lib/Future/Utils.pm +++ b/lib/Future/Utils.pm @@ -639,7 +639,7 @@ sub _fmap !defined $_ or $_->is_ready or $_->cancel for @slots; }); $future->on_cancel( sub { - $_->cancel for @slots; + !defined $_ or $_->is_ready or $_->cancel for @slots; }); return $future; diff --git a/t/36utils-map.t b/t/36utils-map.t index a19c43c..6fbec1c 100644 --- a/t/36utils-map.t +++ b/t/36utils-map.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Fatal; use Future; use Future::Utils qw( fmap_concat fmap_scalar ); @@ -43,6 +44,16 @@ use Future::Utils qw( fmap_concat fmap_scalar ); is_deeply( [ $future->get ], [qw( A B C D E )], '$future->get for fmap_concat out of order' ); } +# fmap_concat cancel +{ + my $f = Future->new; + my $fmap = fmap_concat { $f } foreach => [$f], concurrent => 2; + is(exception { + $fmap->cancel; + }, undef, '$fmap_concat->cancel does not throw on undef slots'); + ok($fmap->is_cancelled, 'was cancelled correctly'); +} + # fmap_scalar no concurrency { my @subf;
On Wed Mar 01 10:15:03 2017, TEAM wrote: Show quoted text
> In some situations, the fmap slots can be undef when ->cancel is > called. ->fail and other states are handled correctly, looks like this > one is just an oversight.
Ahyes; that looks good. Patch applied, will be in next version -- Paul Evans
Released in 0.35 -- Paul Evans