-use Config;
-BEGIN {
- unless ($Config{useithreads}) {
- print "1..0 # SKIP your perl does not support ithreads\n";
- exit 0;
- }
-}
-
-BEGIN {
- unless (eval { require threads }) {
- print "1..0 # SKIP threads.pm not installed\n";
- exit 0;
- }
-}
+use t::threads_check;
use threads;
use threads::shared;
+use t::threads_check;
use strict;
use warnings;
-use Config;
-BEGIN {
- unless ($Config{useithreads}) {
- print "1..0 # SKIP your perl does not support ithreads\n";
- exit 0;
- }
-}
-
-BEGIN {
- unless (eval { require threads }) {
- print "1..0 # SKIP threads.pm not installed\n";
- exit 0;
- }
-}
-
BEGIN {
if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) {
unshift @INC, sub {
--- /dev/null
+package t::threads_check;
+
+sub _skip {
+ print "1..0 # SKIP $_[0]\n";
+ exit 0;
+}
+
+sub import {
+ my ($class, $op) = @_;
+ if ($0 eq '-' && $op) {
+ if ($op eq 'installed') {
+ eval { require threads } or exit 1;
+ }
+ elsif ($op eq 'create') {
+ require threads;
+ threads->create(sub{ 1 })->join;
+ }
+ exit 0;
+ }
+ require Config;
+ if (! $Config::Config{useithreads}) {
+ _skip "your perl does not support ithreads";
+ }
+ elsif (system "$^X", '-Mt::threads_check=installed') {
+ _skip "threads.pm not installed";
+ }
+ elsif (system "$^X", '-Mt::threads_check=create') {
+ _skip "threads broken on this machine";
+ }
+}
+
+1;