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 ###
45 # You have to do it this way or VMS will get confused.
47 print("ok $id - $name\n");
49 print("not ok $id - $name\n");
50 printf("# Failed test at line %d\n", (caller)[2]);
57 ### Start of Testing ###
59 # Tests freeing the Perl interperter for each thread
60 # See http://www.nntp.perl.org/group/perl.perl5.porters/110772 for details
66 my $tid = threads->tid();
67 ok($tid, "Thread $tid started");
71 threads->create('threading_1')->detach();
91 ok($tid, "Thread $tid done");
96 threads->create('threading_1')->detach();
114 ok($COUNT == 5, "Done - $COUNT threads");
118 my $tid = threads->tid();
119 ok($tid, "Thread $tid started");
122 threads->create('threading_2')->detach();
131 ok($tid, "Thread $tid done");
136 threads->create('threading_2')->detach();
146 ok($COUNT == 5, "Done - $COUNT threads");
150 threads->create(sub { })->join();
156 my $tid = threads->tid();
157 ok($tid, "Thread $tid started");
160 threads->create(sub {
161 my $tid = threads->tid();
162 ok($tid, "Thread $tid started");
171 ok($tid, "Thread $tid done");
179 ok($tid, "Thread $tid done");
184 threads->create(sub {
185 threads->create('threading_3')->detach();
196 ok($COUNT == 2, "Done - $COUNT threads");