BEGIN {
if
(
$ENV
{
'PERL_CORE'
}){
chdir
't'
;
unshift
@INC
,
'../lib'
;
}
if
(!
$Config
{
'useithreads'
}) {
print
(
"1..0 # Skip: Perl not compiled with 'useithreads'\n"
);
exit
(0);
}
}
BEGIN {
eval
{
import
omnithreads::shared;
};
if
($@ || !
$omnithreads::shared::threads_shared
) {
print
(
"1..0 # Skip: omnithreads::shared not available\n"
);
exit
(0);
}
$| = 1;
print
(
"1..6\n"
);
};
my
$TEST
;
BEGIN {
share(
$TEST
);
$TEST
= 1;
}
ok(1,
'Loaded'
);
sub
ok {
my
(
$ok
,
$name
) =
@_
;
lock
(
$TEST
);
my
$id
=
$TEST
++;
if
(
$ok
) {
print
(
"ok $id - $name\n"
);
}
else
{
print
(
"not ok $id - $name\n"
);
printf
(
"# Failed test at line %d\n"
, (
caller
)[2]);
}
return
(
$ok
);
}
END {
ok(1,
'Main END block'
)
}
omnithreads->create(
sub
{
eval
"END { ok(1, '1st thread END block') }"
})->
join
();
omnithreads->create(
sub
{
eval
"END { ok(1, '2nd thread END block') }"
})->
join
();
sub
thread {
eval
"END { ok(1, '4th thread END block') }"
;
omnithreads->create(
sub
{
eval
"END { ok(1, '5th thread END block') }"
})->
join
();
}
omnithreads->create(\
&thread
)->
join
();