=head1 NAME
-Thread - manipulate threads in Perl
+Thread - manipulate threads in Perl (for old code only)
=head1 CAVEAT
variables between the threads.
For new code the use of the C<Thread> module is discouraged and
-the direct use use of the C<threads> and C<threads::shared> modules
+the direct use of the C<threads> and C<threads::shared> modules
is encouraged instead.
Finally, note that there are many known serious problems with the
package Thread::Queue;
-our $VERSION = '1.00';
+use strict;
-our $ithreads;
-our $othreads;
+our $VERSION = '1.00';
use Thread qw(cond_wait cond_broadcast);
BEGIN {
use Config;
- $ithreads = $Config{useithreads};
- $othreads = $Config{use5005threads};
- if($ithreads) {
+ if ($Config{useithreads}) {
require 'threads/shared/queue.pm';
- for my $m (qw(new enqueue dequeue dequeue_nb pending)) {
+ for my $meth (qw(new enqueue dequeue dequeue_nb pending)) {
no strict 'refs';
- *{"Thread::Queue::$m"} = \&{"threads::shared::queue::${m}"};
+ *{"Thread::Queue::$meth"} = \&{"threads::shared::queue::$meth"};
}
- } else {
- for my $m (qw(new enqueue dequeue dequeue_nb pending)) {
+ } elsif ($Config{use5005threads}) {
+ for my $meth (qw(new enqueue dequeue dequeue_nb pending)) {
no strict 'refs';
- *{"Thread::Queue::$m"} = \&{"Thread::Queue::${m}_othread"};
+ *{"Thread::Queue::$meth"} = \&{"Thread::Queue::${meth}_othread"};
}
+ } else {
+ require Carp;
+ Carp::croak("This Perl has neither ithreads nor 5005threads");
}
}
=head1 NAME
-Thread::Queue - thread-safe queues
+Thread::Queue - thread-safe queues (for old code only)
+
+=head1 CAVEAT
+
+For new code the use of the C<Thread::Queue> module is discouraged and
+the direct use of the C<threads>, C<threads::shared> and
+C<threads::shared::queue> modules is encouraged instead.
+
+For the whole story about the development of threads in Perl, and why you
+should B<not> be using this module unless you know what you're doing, see the
+CAVEAT of the C<Thread> module.
=head1 SYNOPSIS
}
sub pending_othread : locked : method {
- my $q = shift;
- return scalar(@$q);
+ return scalar(@{(shift)});
}
1;
package Thread::Semaphore;
-use Thread qw(cond_wait cond_broadcast);
+
+use strict;
our $VERSION = '1.00';
+use Thread qw(cond_wait cond_broadcast);
+
BEGIN {
use Config;
- $ithreads = $Config{useithreads};
- $othreads = $Config{use5005threads};
- if($ithreads) {
+ if ($Config{useithreads}) {
require 'threads/shared/semaphore.pm';
- for my $m (qw(new up down)) {
+ for my $meth (qw(new up down)) {
no strict 'refs';
- *{"Thread::Semaphore::$m"} = \&{"threads::shared::semaphore::${m}"};
+ *{"Thread::Semaphore::$meth"} = \&{"threads::shared::semaphore::$meth"};
}
- } else {
- for my $m (qw(new up down)) {
+ } elsif ($Config{use5005threads}) {
+ for my $meth (qw(new up down)) {
no strict 'refs';
- *{"Thread::Semaphore::$m"} = \&{"Thread::Semaphore::${m}_othread"};
+ *{"Thread::Semaphore::$meth"} = \&{"Thread::Semaphore::${meth}_othread"};
}
+ } else {
+ require Carp;
+ Carp::croak("This Perl has neither ithreads nor 5005threads");
}
}
=head1 NAME
-Thread::Semaphore - thread-safe semaphores
+Thread::Semaphore - thread-safe semaphores (for old code only)
+
+=head1 CAVEAT
+
+For new code the use of the C<Thread::Semaphore> module is discouraged and
+the direct use of the C<threads>, C<threads::shared> and
+C<threads::shared::semaphore> modules is encouraged instead.
+
+For the whole story about the development of threads in Perl, and why you
+should B<not> be using this module unless you know what you're doing, see the
+CAVEAT of the C<Thread> module.
=head1 SYNOPSIS