9 Test::More::plan(skip_all => $msg);
12 use Config qw/%Config/;
15 skipall 'This perl wasn\'t built to support threads'
16 unless $Config{useithreads};
17 skipall 'threads required to test thread safety' unless eval "use threads; 1";
23 use Test::More tests => $num;
26 defined and diag "Using threads $_" for $threads::VERSION;
28 if (eval "use Time::HiRes; 1") {
29 defined and diag "Using Time::HiRes $_" for $Time::HiRes::VERSION;
30 *usleep = \&Time::HiRes::usleep;
32 diag 'Using fallback usleep';
34 my $s = int($_[0] / 2.5e5);
40 use Scope::Upper qw/unwind UP/;
48 my $tid = threads->tid();
60 my $foo = unwind $tid .. $tid + 2 => UP;
61 fail "$p: not reached";
64 fail "$p: not reached";
69 is_deeply \@res, [ -1, $tid .. $tid + 2, -2 ], "$p: unwinded correctly";
72 $_->join for map threads->create(\&up1), 1 .. $num;