From: Jerry Hedden Date: Fri, 6 Oct 2006 12:19:41 +0000 (-0700) Subject: threads 1.43 - stringify X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3ab143769e84ecceef90e38e01a51f008592558c;p=p5sagit%2Fp5-mst-13.2.git threads 1.43 - stringify Message-ID: <20061006191941.22457.qmail@web30205.mail.mud.yahoo.com> p4raw-id: //depot/perl@28958 --- diff --git a/MANIFEST b/MANIFEST index aeadf96..e8f0b90 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1155,7 +1155,6 @@ ext/threads/t/stress_cv.t Test with multiple threads, coderef cv argument. ext/threads/t/stress_re.t Test with multiple threads, string cv argument and regexes. ext/threads/t/stress_string.t Test with multiple threads, string cv argument. ext/threads/t/thread.t General ithread tests from thr5005 -ext/threads/typemap ithreads ext/Thread/sync2.tx Test thread synchronisation ext/Thread/sync.tx Test thread synchronisation ext/Thread/Thread/Signal.pm Start a thread to run signal handlers diff --git a/ext/threads/Changes b/ext/threads/Changes index 51e796a..332a3cb 100755 --- a/ext/threads/Changes +++ b/ext/threads/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension threads. +1.43 Fri Oct 6 15:12:07 EDT 2006 + - Stringify threads objects + - Removed 'typemap' file + 1.42 Mon Sep 18 11:17:13 EDT 2006 - Fixes to tests - Move $threads::threads outside of BEGIN block diff --git a/ext/threads/Makefile.PL b/ext/threads/Makefile.PL index c10f046..ee994bb 100755 --- a/ext/threads/Makefile.PL +++ b/ext/threads/Makefile.PL @@ -65,14 +65,23 @@ if (grep { $_ eq 'PERL_CORE=1' } @ARGV) { # Create Makefile WriteMakefile( 'NAME' => 'threads', - 'AUTHOR' => 'Artur Bergman ', + 'AUTHOR' => 'Artur Bergman, Jerry D. Hedden ', 'VERSION_FROM' => 'threads.pm', 'ABSTRACT_FROM' => 'threads.pm', 'PM' => { 'threads.pm' => '$(INST_LIBDIR)/threads.pm', }, 'PREREQ_PM' => { + 'strict' => 0, + 'warnings' => 0, + 'overload' => 0, + 'Config' => 0, + 'Carp' => 0, 'XSLoader' => 0, + + 'ExtUtils::testlib' => 0, + 'Hash::Util' => 0, + 'IO::File' => 0, }, 'INSTALLDIRS' => 'perl', diff --git a/ext/threads/README b/ext/threads/README index b1aca16..89ee954 100755 --- a/ext/threads/README +++ b/ext/threads/README @@ -1,4 +1,4 @@ -threads version 1.42 +threads version 1.43 ==================== This module exposes interpreter threads to the Perl level. diff --git a/ext/threads/t/basic.t b/ext/threads/t/basic.t index 7e7fecf..e693a00 100755 --- a/ext/threads/t/basic.t +++ b/ext/threads/t/basic.t @@ -31,7 +31,7 @@ sub ok { BEGIN { $| = 1; - print("1..32\n"); ### Number of tests that will be run ### + print("1..33\n"); ### Number of tests that will be run ### }; use threads; @@ -160,4 +160,9 @@ ok(31, ! defined($thrx), 'No object'); $thrx = threads->object(0); ok(32, ! defined($thrx), 'No object'); +import threads 'stringify'; +$thr1 = threads->create(sub {}); +ok(33, "$thr1" eq $thr1->tid(), 'Stringify'); +$thr1->join(); + # EOF diff --git a/ext/threads/t/thread.t b/ext/threads/t/thread.t index ef68444..710685d 100644 --- a/ext/threads/t/thread.t +++ b/ext/threads/t/thread.t @@ -171,7 +171,7 @@ package main; # bugid #24165 -run_perl(prog => 'use threads 1.42;' . +run_perl(prog => 'use threads 1.43;' . 'sub a{threads->create(shift)} $t = a sub{};' . '$t->tid; $t->join; $t->tid', nolib => ($ENV{PERL_CORE}) ? 0 : 1, diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm index 7574487..f7211b5 100755 --- a/ext/threads/threads.pm +++ b/ext/threads/threads.pm @@ -5,7 +5,7 @@ use 5.008; use strict; use warnings; -our $VERSION = '1.42'; +our $VERSION = '1.43'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -54,6 +54,9 @@ sub import my $flag = shift; $threads::thread_exit_only = $flag =~ /^thread/i; + } elsif ($sym =~ /^str/i) { + import overload ('""' => \&tid); + } elsif ($sym =~ /all/) { push(@EXPORT, qw(yield)); @@ -129,11 +132,14 @@ threads - Perl interpreter-based threads =head1 VERSION -This document describes threads version 1.42 +This document describes threads version 1.43 =head1 SYNOPSIS - use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only'); + use threads ('yield', + 'stack_size' => 64*4096, + 'exit' => 'threads_only', + 'stringify'); sub start_thread { my @args = @_; @@ -163,6 +169,7 @@ This document describes threads version 1.42 # Get a thread's ID $tid = threads->tid(); $tid = $thr->tid(); + $tid = "$thr"; # Give other threads a chance to run threads->yield(); @@ -322,6 +329,17 @@ thread in a program being 0, and incrementing by 1 for every thread created. Class method that allows a thread to obtain its own ID. +=item "$thr" + +If you add the C import option to your C declaration, +then using a threads object in a string or a string context (e.g., as a hash +key) will cause its ID to be used as the value: + + use threads qw(stringify); + + my $thr = threads->create(...); + print("Thread $thr started...\n"); # Prints out: Thread 1 started... + =item threads->object($tid) This will return the I object for the I thread associated @@ -886,7 +904,7 @@ L Discussion Forum on CPAN: L Annotated POD for L: -L +L L, L diff --git a/ext/threads/typemap b/ext/threads/typemap deleted file mode 100644 index 269d412..0000000 --- a/ext/threads/typemap +++ /dev/null @@ -1,9 +0,0 @@ -ithread * T_ITHREAD - -INPUT -T_ITHREAD - $var = SV_to_ithread(aTHX_ $arg) - -OUTPUT -T_ITHREAD - ithread_to_SV(aTHX_ $arg, $var, classname, TRUE);