Skip to content

Commit

Permalink
Merge pull request #3052 from vrurg/perl-version-threadsafe
Browse files Browse the repository at this point in the history
Protect class Perl version method with Lock
  • Loading branch information
vrurg committed Jul 15, 2019
2 parents 56af07b + 4c10373 commit 4eb4c0c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/Perl.pm6
Expand Up @@ -15,9 +15,12 @@ class Perl does Systemic {
method KERNELnames { <darwin linux freebsd openbsd netbsd dragonfly win32 browser> }

my %version-cache;
my Lock $version-cache-lock .= new;
method version {
my $comp-ver = nqp::p6box_s(nqp::getcomp('perl6').language_version());
%version-cache{$comp-ver} //= Version.new($comp-ver);
$version-cache-lock.protect: {
my $comp-ver = nqp::p6box_s(nqp::getcomp('perl6').language_version());
%version-cache{$comp-ver} //= Version.new($comp-ver);
}
}
}

Expand Down

0 comments on commit 4eb4c0c

Please sign in to comment.