# New Ticket Created by Erik Ferguson
# Please include the string: [perl #125908]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=125908 >
When two greps are used in parallel on one supply produced by
IO::Notification.watch_path, greps that match are triggered twice. Run
the following code, then in the same directory `touch watchfile`. Note
that I'm also using unique to filter things, as touching a file produces
a number of FileChanged events.
my $paths = IO::Notification.watch_path('.')\
.grep(*.event.isa(FileChangeEvent::FileChanged))\
.unique(:as(*.path), :expires(5))\
.map(*.path);
my $watch = $paths.grep(* ~~ /watchfile/)\
.act(-> $x {
say "got file change: " ~ $x.perl;
});
my $never = $paths.grep(* ~~ /shouldneverexecute/)\
.act(-> $x {
say "should never execute: " ~ $x.perl;
});
sleep;
Output:
got file change: "watchfile"
got file change: "watchfile"
The expected output should be only a single line, not two. I also
noticed that each additional grep I add to the supply yields an
additional line of the same output.
I tried this with a plain supply and could not reproduce the problem:
my $s = Supply.new();
my $watch = $s.grep(* ~~ /1/)\
.act(-> $x {
say "got one";
});
my $never = $s.grep(* ~~ /shouldneverexecute/)\
.act(-> $x {
say "should never execute";
});
$s.emit(1);
$s.emit(2);
sleep;
This outputs "got one" a single time, as expected.
Perl6 version info: 2015.07.1-161-gf7cfe9d built on MoarVM version
2015.07-57-gec051f5