develooper Front page | perl.perl5.porters | Postings from May 2008

[PATCH] threads::shared 1.19

Thread Next
From:
Jerry D. Hedden
Date:
May 7, 2008 11:03
Subject:
[PATCH] threads::shared 1.19
Message ID:
1ff86f510805071102p239965adg5b2a189d0ad81c8@mail.gmail.com
Attached patch fixes return value of ref() on shared refs of
refs when stored in other shared structures.  (See below
for sample test.)

The patch also makes t/stress.t not fail if thread
creations fail due to ENOMEM.


Sample program:

    #!/usr/bin/perl

    use strict;
    use warnings;

    use threads;
    use threads::shared;
    use Test::More ('tests' => 3);

    my $x : shared;
    my $y : shared;
    my $z : shared;

    $x = \$y;
    $y = \$z;
    is(ref($x), 'REF', '$x is a REF');

    my @q : shared = ($x);
    is(ref($q[0]), 'REF', '$q[0] is a REF');

    my $w = $q[0];
    is(ref($w), 'REF', '$w is a REF');

    # EOF

Output before patch:

    1..3
    ok 1 - $x is a REF
    not ok 2 - $q[0] is a REF
    #   Failed test '$q[0] is a REF'
    #   at stuff/bugs/debug.pl line 19.
    #          got: 'SCALAR'
    #     expected: 'REF'
    not ok 3 - $w is a REF
    #   Failed test '$w is a REF'
    #   at stuff/bugs/debug.pl line 22.
    #          got: 'SCALAR'
    #     expected: 'REF'
    # Looks like you failed 2 tests of 3.

Output after patch:

    1..3
    ok 1 - $x is a REF
    ok 2 - $q[0] is a REF
    ok 3 - $w is a REF

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About