Skip to content

Commit 32b51f7

Browse files
committed
Go all in on Promises.
"Don't worry about it" - let the scheduler handle overscheduling. Also thread the non-proc version.
1 parent 89bf0ab commit 32b51f7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

xt/duplicates.t

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ plan +@files;
2626
my $max-jobs = %*ENV<TEST_THREADS> // 2;
2727
my %output;
2828

29-
sub test-promise($promise) {
30-
my $file = $promise.command[*-1];
31-
test-it(%output{$file}, $file);
32-
}
33-
3429
sub test-it(Str $output, Str $file) {
3530
my $ok = True;
3631

@@ -76,15 +71,18 @@ for @files -> $file {
7671
my $a = Proc::Async.new($*EXECUTABLE-NAME, '--doc', $file);
7772
%output{$file} = '';
7873
$a.stdout.tap(-> $buf { %output{$file} = %output{$file} ~ $buf });
79-
push @jobs: $a.start;
80-
if +@jobs > $max-jobs {
81-
test-promise(await @jobs.shift)
82-
}
74+
push @jobs: Promise.anyof(
75+
$a.start.then({ test-it(%output{$file}, $file) }),
76+
Promise.in(60)
77+
);
8378
} else {
84-
test-it($file.IO.slurp, $file);
79+
push @jobs: Promise.anyof(
80+
start { test-it($file.IO.slurp, $file) },
81+
Promise.in(60)
82+
);
8583
}
8684
}
8785

88-
for @jobs.map: {await $_} -> $r { test-promise($r) }
86+
await Promise.allof(@jobs);
8987

9088
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)