Skip to content

Commit

Permalink
Simplify await()
Browse files Browse the repository at this point in the history
You should do the Awaitable role to be able to await on, not be a
Promise, Channel or Supply per se.
  • Loading branch information
lizmat committed Jun 29, 2018
1 parent 587cd4f commit ea16138
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/core/asyncops.pm6
Expand Up @@ -23,7 +23,7 @@ multi sub await(Any:U $x) {
multi sub await(Any:D $x) {
die "Must specify a Promise, Channel, or Supply to await on (got a $x.^name())";
}
multi sub await(Promise:D $p) {
multi sub await(Awaitable:D $p) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
($_ but X::Await::Died(Backtrace.new(5))).rethrow
Expand All @@ -32,24 +32,6 @@ multi sub await(Promise:D $p) {
my $*RAKUDO-AWAIT-BLOCKING := True;
$*AWAITER.await($p)
}
multi sub await(Channel:D $c) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
($_ but X::Await::Died(Backtrace.new(5))).rethrow
}
}
my $*RAKUDO-AWAIT-BLOCKING := True;
$*AWAITER.await($c)
}
multi sub await(Supply:D $s) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
($_ but X::Await::Died(Backtrace.new(5))).rethrow
}
}
my $*RAKUDO-AWAIT-BLOCKING := True;
$*AWAITER.await($s)
}
multi sub await(Iterable:D $i) { eager $i.eager.map({ await $_ }) }
multi sub await(*@awaitables) { eager @awaitables.eager.map({await $_}) }

Expand Down

0 comments on commit ea16138

Please sign in to comment.