develooper Front page | perl.perl5.porters | Postings from April 2003

[perl #21998] perlthrtut uses Thread::.* instead of threads::shared::.* in examples

Thread Next
From:
Ido Trivizki
Date:
April 21, 2003 08:10
Subject:
[perl #21998] perlthrtut uses Thread::.* instead of threads::shared::.* in examples
Message ID:
rt-21998-55393.4.61922852303317@bugs6.perl.org
# New Ticket Created by  Ido Trivizki 
# Please include the string:  [perl #21998]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21998 >


Here's a patch:

--- perlthrtut.pod Thu Nov 28 17:10:04 2002
+++ perlthrtutpatched.pod Sat Apr 19 14:28:45 2003
@@ -684,9 +684,9 @@
 this:
 
     use threads; 
-    use Thread::Queue;
+    use threads::shared::queue;
 
-    my $DataQueue = Thread::Queue->new; 
+    my $DataQueue = threads::shared::queue->new; 
     $thr = threads->new(sub { 
         while ($DataElement = $DataQueue->dequeue) { 
             print "Popped $DataElement off the queue\n";
@@ -700,7 +700,7 @@
     $DataQueue->enqueue(undef);
     $thr->join;
 
-You create the queue with C<new Thread::Queue>.  Then you can
+You create the queue with C<new threads::shared::queue>.  Then you can
 add lists of scalars onto the end with enqueue(), and pop scalars off
 the front of it with dequeue().  A queue has no fixed size, and can grow
 as needed to hold everything pushed on to it.
@@ -725,9 +725,9 @@
 gives a quick demonstration:
 
     use threads qw(yield); 
-    use Thread::Semaphore; 
+    use threads::shared::semaphore; 
 
-    my $semaphore = new Thread::Semaphore; 
+    my $semaphore = new threads::shared::semaphore; 
     my $GlobalVariable : shared = 0;
 
     $thr1 = new threads \&sample_sub, 1; 
@@ -770,8 +770,8 @@
 of these defaults simply by passing in different values:
 
     use threads;
-    use Thread::Semaphore;
-    my $semaphore = Thread::Semaphore->new(5);
+    use threads::shared::semaphore;
+    my $semaphore = threads::shared::semaphore->new(5);
                     # Creates a semaphore with the counter set to five
 
     $thr1 = threads->new(\&sub1);
@@ -884,9 +884,9 @@
     4  use strict;
     5
     6  use threads;
-    7  use Thread::Queue;
+    7  use threads::shared::queue;
     8
-    9  my $stream = new Thread::Queue;
+    9  my $stream = new threads::shared::queue;
     10 my $kid    = new threads(\&check_num, $stream, 2);
     11
     12 for my $i ( 3 .. 1000 ) {
@@ -899,7 +899,7 @@
     19 sub check_num {
     20     my ($upstream, $cur_prime) = @_;
     21     my $kid;
-    22     my $downstream = new Thread::Queue;
+    22     my $downstream = new threads::shared::queue;
     23     while (my $num = $upstream->dequeue) {
     24         next unless $num % $cur_prime;
     25         if ($kid) {


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=docs
    severity=low
---
Site configuration information for perl v5.8.0:

Configured by ActiveState at Tue Feb  4 18:07:44 2003.

Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth="C:\Perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl v5.8.0:
    C:/Perl/lib
    C:/Perl/site/lib
    .

---
Environment for perl v5.8.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\Bpl\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Perl\bin
    PERL_BADLANG (unset)
    SHELL (unset)



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About