5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 if (! $Config{'useithreads'}) {
11 print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
16 use ExtUtils::testlib;
22 require threads::shared;
23 import threads::shared;
25 if ($@ || ! $threads::shared::threads_shared) {
26 print("1..0 # Skip: threads::shared not available\n");
31 print("1..29\n"); ### Number of tests that will be run ###
48 # You have to do it this way or VMS will get confused.
50 print("ok $id - $name\n");
52 print("not ok $id - $name\n");
53 printf("# Failed test at line %d\n", (caller)[2]);
60 ### Start of Testing ###
62 # Tests freeing the Perl interperter for each thread
63 # See http://www.nntp.perl.org/group/perl.perl5.porters/110772 for details
69 my $tid = threads->tid();
70 ok($tid, "Thread $tid started");
74 threads->create('threading_1')->detach();
94 ok($tid, "Thread $tid done");
99 threads->create('threading_1')->detach();
117 ok($COUNT == 5, "Done - $COUNT threads");
121 my $tid = threads->tid();
122 ok($tid, "Thread $tid started");
125 threads->create('threading_2')->detach();
134 ok($tid, "Thread $tid done");
139 threads->create('threading_2')->detach();
149 ok($COUNT == 5, "Done - $COUNT threads");
153 threads->create(sub { })->join();
159 my $tid = threads->tid();
160 ok($tid, "Thread $tid started");
163 threads->create(sub {
164 my $tid = threads->tid();
165 ok($tid, "Thread $tid started");
174 ok($tid, "Thread $tid done");
182 ok($tid, "Thread $tid done");
187 threads->create(sub {
188 threads->create('threading_3')->detach();
199 ok($COUNT == 2, "Done - $COUNT threads");