Fixed with https://github.com/rakudo/rakudo/commit/91543fe310 , thanks for the
report!
> On 31 Oct 2017, at 00:32, Norman Gaywood wrote:
>
> Hmm, in developing this I was using an old perl6:
>
> This is rakudo version 2015.11-554-g3b4964b built on MoarVM version
> 2015.11-49-g27f15d9 implementing Perl v6.b.
>
> I updated perl6 to the one that comes with Fedora:
>
> This is Rakudo version 2017.08 built on MoarVM version 2017.08.1 implementing
> Perl 6.c
>
> Now when I run this program I get an exception when I do:
>
> close $dir-channel;
>
> Tried to get the result of a broken Promise
> in block at ./traverse-dir0.p6 line 7
>
> Original exception:
> Cannot resolve caller close(Channel); none of these signatures match:
> (IO::Handle:D $fh)
> in block at ./traverse-dir0.p6 line 12
>
> However, if I change the line 12 to:
>
> $dir-channel.close;
>
> The program does not throw and exception on this line and runs properly.
>
>
>
> On 30 October 2017 at 16:58, Norman Gaywood wrote:
> Looking at Andrew Shitov's new "Using Perl6" book and was playing around with
> his "94. Parallel file processing" and came up with the following (I think
> nice) example.
>
> # There is a thread to populate $dir-channel by reading filenames in a
> directory with dir()
> # and $N worker threads to read the filenames from the $dir-channel.
>
> use v6;
>
> sub MAIN( $dir = ".", :$N = 4 ) {
>
> my $dir-channel = Channel.new();
> my $dir-read = start {
> $dir-channel.send( $_ ) for dir $dir;
> close $dir-channel;
> }
>
> my @workers = (^$N).map: {
> start {
> while my $file = $dir-channel.receive() {
> say $file.path;
> }
> CATCH {
> when X::Channel::ReceiveOnClosed { .resume }
> }
> }
> }
>
> await $dir-read, @workers;
> }
>
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412 Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>
>
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412 Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html