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");
30 if (($] < 5.008002) && ($threads::shared::VERSION < 0.92)) {
31 print("1..0 # Skip: Needs threads::shared 0.92 or later\n");
36 print("1..78\n"); ### Number of tests that will be run ###
53 # You have to do it this way or VMS will get confused.
55 print("ok $id - $name\n");
57 print("not ok $id - $name\n");
58 printf("# Failed test at line %d\n", (caller)[2]);
65 ### Start of Testing ###
67 # Tests freeing the Perl interperter for each thread
68 # See http://www.nntp.perl.org/group/perl.perl5.porters/110772 for details
77 my $tid = threads->tid();
78 ok($tid, "Thread $tid started");
88 my $next = 'th' . ($tid+1);
89 my $th = threads->create($next);
91 # Last thread signals first
95 # Wait until signalled by another thread
96 while (! exists($READY{$tid})) {
99 $other = delete($READY{$tid});
101 ok($tid, "Thread $tid received signal from $other");
107 my $tid = threads->tid();
113 ok($tid, "Thread $tid done");
116 # Signal another thread to go
120 my $tid = threads->tid();
122 ok($tid, "Thread $tid signalling $other");
125 $READY{$other} = $tid;
126 cond_broadcast(%READY);
201 my $tid = threads->tid();
208 ok(1, "Thread $tid getting return from thread $other");
209 my $ret = threads->object($other)->join();
210 ok($ret == $other, "Thread $tid saw that thread $other returned $ret");
217 return (threads->tid());
222 my $tid = threads->tid();
228 ok(1, "Thread $tid getting return from thread $other");
229 my $ret = threads->object($other)->join();
230 ok($ret == $other, "Thread $tid saw that thread $other returned $ret");
238 return (threads->tid());
243 my $tid = threads->tid();
250 ok(1, "Thread $tid getting return from thread $other");
251 my $ret = threads->object($other)->join();
252 ok($ret == $other, "Thread $tid saw that thread $other returned $ret");
259 return (threads->tid());
264 my $tid = threads->tid();
270 ok(1, "Thread $tid getting return from thread $other");
271 my $ret = threads->object($other)->join();
272 ok($ret == $other, "Thread $tid saw that thread $other returned $ret");
280 return (threads->tid());
287 threads->create('th1');
290 while ($COUNT < 17) {
296 ok($COUNT == 17, "Done - $COUNT threads");