Navigation Menu

Skip to content

Commit

Permalink
hotfix for winner swallowing last.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Nov 21, 2013
1 parent 3e53dd5 commit 2622c63
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/vm/jvm/core/Channel.pm
Expand Up @@ -92,10 +92,12 @@ my class Channel {
}

method list($self:) {
my $condition = False;
map {
last if $condition;
winner $self {
more * { $_ }
done * { last }
done * { $condition = True; Nil }
}
}, 0..*; # until we have a listless map { }
}
Expand Down
6 changes: 4 additions & 2 deletions src/vm/jvm/core/Supply.pm
Expand Up @@ -51,10 +51,12 @@ my role Supply {
method list() {
# Use a Channel to handle any asynchrony.
my $c = self.Channel;
my $condition = False;
(1..*).map(sub ($) {
last if $condition;
winner $c {
more * { return $_ }
done * { last }
more * { $_ }
done * { $condition = False; Nil }
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/vm/jvm/core/asyncops.pm
Expand Up @@ -124,10 +124,10 @@ sub WINNER(@winner_args, *@pieces, :$wild_done, :$wild_more, :$wait, :$wait_time
}
# if we only had promises, we can block on "anyof".
}
if $has_channels {
if $has_channels || (@promises_only == 0) {
Thread.yield();
} else {
Promise.anyof(@promises_only).result;
Promise.anyof(|@promises_only).result;
}
}
}

0 comments on commit 2622c63

Please sign in to comment.