Hi,

I am trying to use the CompUnit module. I thought I had it working, but then found that units were not being replaced.

I reduced the code to:

<pre>

use v6.c;
use nqp;
'cache'.IO.unlink if 'cache'.IO ~~ e;
my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix=>'cache'.IO); my $precomp = CompUnit::PrecompilationRepository::Default.new(store=> $precomp-store );
my $key = nqp::sha1('test.pod6');

'test.pod6'.IO.spurt(q:to/--END--/);
    =begin pod
    =TITLE More and more

    Some text

    =end pod
    --END--
$precomp.precompile('test.pod6'.IO, $key, :force);
my $handle = $precomp.load( $key )[0];
my $resurrected = nqp::atkey($handle.unit,'$=pod')[0];
say $resurrected.contents[1].contents[0];


'test.pod6'.IO.spurt(q:to/--END--/);
    =begin pod
    =TITLE More and more

    Some more text added

    =end pod
    --END--
# $precomp-store.unlock;
# fails with:
# Attempt to unlock mutex by thread not holding it
#  in block <unit> at comp-test.p6 line 30

$precomp.precompile('test.pod6'.IO, $key, :force);
my $new-handle = $precomp.load($key)[0];
my $new-resurrected = nqp::atkey($handle.unit,'$=pod')[0];
say $new-resurrected.contents[1].contents[0];
</pre>

The output is always:

Some text

Some text


In other words the new version of test.pod6 is not being added to the CompUnit object.

I looked at the code for 'Precompilation::Repository.pm6' and at line 231, if :force is True, then the new code should be precompiled.

However, I have noticed the directory for the Repository has a lock file.

Is that why I can't update the Repository?

If not, what am I doing wrong here?

How can I change what's in the CompUnit?

How can I delete what's in the CompUnit?

Regards


Reply via email to