"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core.c/CompUnit/PrecompilationStore/File.pm6" between
rakudo-2020.08.2.tar.gz and rakudo-2020.09.tar.gz

About: Rakudo is a compiler for the Perl 6 programming language.

File.pm6  (rakudo-2020.08.2):File.pm6  (rakudo-2020.09)
skipping to change at line 121 skipping to change at line 121
--> Bool:D) { --> Bool:D) {
my $result := self.CompUnit::PrecompilationUnit::is-up-to-date($depe ndency, :$check-source); my $result := self.CompUnit::PrecompilationUnit::is-up-to-date($depe ndency, :$check-source);
$!store.remove-from-cache($.id) unless $result; $!store.remove-from-cache($.id) unless $result;
$result $result
} }
} }
has IO::Path:D $.prefix is built(:bind) is required; has IO::Path:D $.prefix is built(:bind) is required;
has IO::Handle $!lock; has IO::Handle $!lock;
has int $!wont-lock;
has int $!lock-count; has int $!lock-count;
has $!loaded; has $!loaded;
has $!dir-cache; has $!dir-cache;
has $!compiler-cache; has $!compiler-cache;
has Lock $!update-lock; has Lock $!update-lock;
submethod TWEAK(--> Nil) { submethod TWEAK(--> Nil) {
$!update-lock := Lock.new; $!update-lock := Lock.new;
if $*W -> $World {
$!wont-lock = 1 if $World.is_precompilation_mode;
}
$!loaded := nqp::hash; $!loaded := nqp::hash;
$!dir-cache := nqp::hash; $!dir-cache := nqp::hash;
$!compiler-cache := nqp::hash; $!compiler-cache := nqp::hash;
} }
method new-unit(|c) { method new-unit(|c) {
CompUnit::PrecompilationUnit::File.new(|c, :store(self)) CompUnit::PrecompilationUnit::File.new(|c, :store(self))
} }
method !dir( method !dir(
skipping to change at line 171 skipping to change at line 167
} }
method path( method path(
CompUnit::PrecompilationId:D $compiler-id, CompUnit::PrecompilationId:D $compiler-id,
CompUnit::PrecompilationId:D $precomp-id, CompUnit::PrecompilationId:D $precomp-id,
Str:D :$extension = '' Str:D :$extension = ''
) { ) {
self!dir($compiler-id, $precomp-id).add($precomp-id ~ $extension) self!dir($compiler-id, $precomp-id).add($precomp-id ~ $extension)
} }
method !lock(--> Nil) { method !lock($path --> Nil) {
unless $!wont-lock { $!update-lock.lock;
$!update-lock.lock; $!lock := "$path.lock".IO.open(:create, :rw)
$!lock := $.prefix.add('.lock').open(:create, :rw) unless $!lock;
unless $!lock; $!lock.lock if $!lock-count++ == 0;
$!lock.lock if $!lock-count++ == 0;
}
} }
method unlock() { method unlock() {
if $!wont-lock { LEAVE $!update-lock.unlock;
Nil die "unlock when we're not locked!" if $!lock-count == 0;
}
else { $!lock-count-- if $!lock-count > 0;
LEAVE $!update-lock.unlock; if $!lock && $!lock-count == 0 {
die "unlock when we're not locked!" if $!lock-count == 0; $!lock.unlock;
$!lock.close;
$!lock-count-- if $!lock-count > 0; $!lock := IO::Handle;
if $!lock && $!lock-count == 0 {
$!lock.unlock;
$!lock.close;
$!lock := IO::Handle;
}
True
} }
True
} }
method load-unit( method load-unit(
CompUnit::PrecompilationId:D $compiler-id, CompUnit::PrecompilationId:D $compiler-id,
CompUnit::PrecompilationId:D $precomp-id CompUnit::PrecompilationId:D $precomp-id
) { ) {
$!update-lock.protect: { $!update-lock.protect: {
my str $key = $precomp-id.Str; my str $key = $precomp-id.Str;
nqp::ifnull( nqp::ifnull(
nqp::atkey($!loaded,$key), nqp::atkey($!loaded,$key),
do { do {
my $path := self.path($compiler-id, $precomp-id); my $path := self.path($compiler-id, $precomp-id);
$path.e $path.s
?? nqp::bindkey($!loaded,$key, ?? nqp::bindkey($!loaded,$key,
CompUnit::PrecompilationUnit::File.new( CompUnit::PrecompilationUnit::File.new(
:id($precomp-id), :$path, :store(self))) :id($precomp-id), :$path, :store(self)))
!! Nil !! Nil
} }
) )
} }
} }
method load-repo-id( method load-repo-id(
CompUnit::PrecompilationId:D $compiler-id, CompUnit::PrecompilationId:D $compiler-id,
CompUnit::PrecompilationId:D $precomp-id CompUnit::PrecompilationId:D $precomp-id
) { ) {
my $path := self.path($compiler-id, $precomp-id, :extension<.repo-id>); my $path := self.path($compiler-id, $precomp-id, :extension<.repo-id>);
$path.e $path.s
?? $path.slurp ?? $path.slurp
!! Nil !! Nil
} }
method remove-from-cache(CompUnit::PrecompilationId:D $precomp-id) { method remove-from-cache(CompUnit::PrecompilationId:D $precomp-id) {
$!update-lock.protect: { $!update-lock.protect: {
nqp::deletekey($!loaded,$precomp-id.Str); nqp::deletekey($!loaded,$precomp-id.Str);
} }
} }
method destination( method destination(
CompUnit::PrecompilationId:D $compiler-id, CompUnit::PrecompilationId:D $compiler-id,
CompUnit::PrecompilationId:D $precomp-id, CompUnit::PrecompilationId:D $precomp-id,
Str:D :$extension = '' Str:D :$extension = ''
--> IO::Path:D) { --> IO::Path:D) {
# have a writable prefix, assume it's a directory # have a writable prefix, assume it's a directory
if $!prefix.w { if $!prefix.w {
self!lock(); self!lock(self!file($compiler-id, $precomp-id));
self!file($compiler-id, $precomp-id, :$extension); self!file($compiler-id, $precomp-id, :$extension);
} }
# directory creation successful and writeable # directory creation successful and writeable
elsif $!prefix.mkdir && $!prefix.w { elsif $!prefix.mkdir && $!prefix.w {
# make sure we have a tag in it # make sure we have a tag in it
$!prefix.child('CACHEDIR.TAG').spurt: $!prefix.child('CACHEDIR.TAG').spurt:
'Signature: 8a477f597d28d172789f06886806bc55 'Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by Rakudo. # This file is a cache directory tag created by Rakudo.
 End of changes. 8 change blocks. 
28 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)