X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-detach.t;h=0631264a63fa331247b7eeb95ae5c494c83a9977;hb=5df33e24c91c6ebd942de8ed5eb45dd4c1b24269;hp=32339aed251d7deef0323c1441d54627d7130146;hpb=4c809697b9f79c6f752911f19642becfdff2dd87;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/t/11-detach.t b/t/11-detach.t index 32339ae..0631264 100644 --- a/t/11-detach.t +++ b/t/11-detach.t @@ -3,20 +3,10 @@ use strict; use warnings; -use Config qw/%Config/; +use lib 't/lib'; +use Thread::Cleanup::TestThreads; -BEGIN { - if (!$Config{useithreads}) { - require Test::More; - Test::More->import; - plan(skip_all => 'This perl wasn\'t built to support threads'); - } -} - -use threads; -use threads::shared; - -use Test::More tests => 5 * (2 + 2 + 1) + 1; +use Test::More 'no_plan'; use Thread::Cleanup; @@ -62,19 +52,14 @@ sub cb { sleep 1; } -my @tids; - -my @t = map { +my @threads = map { local $x = $_; - my $thr = threads->create(\&cb, $_); - push @tids, $thr->tid; - $thr; + spawn(\&cb, $_); } 0 .. 4; -diag "Using threads $threads::VERSION"; -diag "Using threads::shared $threads::shared::VERSION"; +my @tids = map $_->tid, @threads; -$_->detach for @t; +$_->detach for @threads; sleep 2;