perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestModperl ithreads.pm
Date Sat, 19 Jul 2003 10:17:22 GMT
stas        2003/07/19 03:17:21

  Modified:    t/response/TestModperl ithreads.pm
  Log:
  test shared vs. non-shared variables
  
  Revision  Changes    Path
  1.2       +20 -2     modperl-2.0/t/response/TestModperl/ithreads.pm
  
  Index: ithreads.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/ithreads.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ithreads.pm	19 Jul 2003 09:57:05 -0000	1.1
  +++ ithreads.pm	19 Jul 2003 10:17:20 -0000	1.2
  @@ -17,7 +17,7 @@
   sub handler {
       my $r = shift;
   
  -    plan $r, tests => 2, have
  +    plan $r, tests => 4, have
           have_threads,
           {"perl >= 5.8.1 is required (this is $])" => ($] >= 5.008001)};
   
  @@ -38,7 +38,25 @@
                                      debug "2nd TID is $tid" if defined $tid;
                                      return 2;
                                  });
  -        ok $thr->join == 2;
  +        ok t_cmp(2, $thr->join, "thread callback returned value");
  +    }
  +
  +    {
  +        require threads::shared;
  +        my $counter_priv          = 1;
  +        my $counter_shar : shared = 1;
  +        my $thr = threads->new(sub : locked { 
  +                                   my $tid = threads->self->tid; 
  +                                   debug "2nd TID is $tid" if defined $tid;
  +                                   $counter_priv += $counter_priv for 1..10;
  +                                   $counter_shar += $counter_shar for 1..10;
  +                                   return 2;
  +                               });
  +        $counter_priv += $counter_priv for 1..10;
  +        $counter_shar += $counter_shar for 1..10;
  +        my $ret = $thr->join;
  +        ok t_cmp(2**20, $counter_shar, "shared counter");
  +        ok t_cmp(2**10, $counter_priv, "private counter");
       }
   
       Apache::OK;
  
  
  

Mime
View raw message