Skip to content

Commit

Permalink
Don't index into the same hash from multiple threads
Browse files Browse the repository at this point in the history
  • Loading branch information
skids committed Dec 20, 2015
1 parent 2415a22 commit 09ca76e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Test/Screen.pm6
Expand Up @@ -101,8 +101,12 @@ sub screen-keystrokes (*@keystrokes) is export {

sub get-hardcopies (:$inscrollback = False; :$onscreen = True) is export {
my %res;
for tested-screens() -> $sn, $ss {
%res{$sn} := $ = Nil;
}
await (for tested-screens() -> $sn, $ss {
start {
my $sr := %res{$sn};
my $info = $ss.query('info');
my ($fn, $fh) = |tempfile();
$info ~~ m|\( \d+ \, \d+ \) \/ \( \d+ \, (\d+) \) \+ (\d+)|;
Expand All @@ -112,14 +116,11 @@ sub get-hardcopies (:$inscrollback = False; :$onscreen = True) is export {
await Promise.anyof($p, Promise.in(5));
my $output = $fh.slurp-rest;
if ($output.chars) {
%res{$sn} = $output.lines;
$sr = $output.lines;
if $inscrollback and not $onscreen {
%res{$sn} = %res{$sn}[0..^$scrollback];
$sr = $sr[0..^$scrollback];
}
}
else {
%res{$sn} = Nil;
}
$fn.IO.unlink;
}
});
Expand Down

0 comments on commit 09ca76e

Please sign in to comment.