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";
22 use Scope::Upper qw/unwind UP SU_THREADSAFE/;
27 skipall 'This Scope::Upper isn\'t thread safe' unless SU_THREADSAFE;
28 plan tests => ($num = 30);
29 defined and diag "Using threads $_" for $threads::VERSION;
30 if (eval "use Time::HiRes; 1") {
31 defined and diag "Using Time::HiRes $_" for $Time::HiRes::VERSION;
32 *usleep = \&Time::HiRes::usleep;
34 diag 'Using fallback usleep';
36 my $s = int($_[0] / 2.5e5);
45 my $tid = threads->tid();
57 my $foo = unwind $tid .. $tid + 2 => UP;
58 fail "$p: not reached";
61 fail "$p: not reached";
66 is_deeply \@res, [ -1, $tid .. $tid + 2, -2 ], "$p: unwinded correctly";
69 $_->join for map threads->create(\&up1), 1 .. $num;