summaryrefslogtreecommitdiff
path: root/ext/Thread
diff options
context:
space:
mode:
Diffstat (limited to 'ext/Thread')
-rw-r--r--ext/Thread/Makefile.PL4
-rw-r--r--ext/Thread/Thread.pm241
-rw-r--r--ext/Thread/create.tx4
-rw-r--r--ext/Thread/die.tx4
-rw-r--r--ext/Thread/die2.tx4
-rw-r--r--ext/Thread/io.tx4
-rw-r--r--ext/Thread/join.tx4
-rw-r--r--ext/Thread/join2.tx4
-rw-r--r--ext/Thread/list.tx4
-rw-r--r--ext/Thread/lock.tx4
-rw-r--r--ext/Thread/queue.tx4
-rw-r--r--ext/Thread/specific.tx4
-rw-r--r--ext/Thread/sync.tx4
-rw-r--r--ext/Thread/sync2.tx4
-rw-r--r--ext/Thread/unsync.tx4
-rw-r--r--ext/Thread/unsync2.tx4
-rw-r--r--ext/Thread/unsync3.tx4
-rw-r--r--ext/Thread/unsync4.tx4
18 files changed, 2 insertions, 307 deletions
diff --git a/ext/Thread/Makefile.PL b/ext/Thread/Makefile.PL
index e67fbb7e26..fc09e7fa43 100644
--- a/ext/Thread/Makefile.PL
+++ b/ext/Thread/Makefile.PL
@@ -1,7 +1,7 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Thread',
- VERSION_FROM => 'Thread.pm',
- MAN3PODS => {}
+ VERSION => '2.00',
+ MAN3PODS => {}
);
diff --git a/ext/Thread/Thread.pm b/ext/Thread/Thread.pm
deleted file mode 100644
index 6220a601fe..0000000000
--- a/ext/Thread/Thread.pm
+++ /dev/null
@@ -1,241 +0,0 @@
-package Thread;
-require Exporter;
-use XSLoader ();
-our($VERSION, @ISA, @EXPORT);
-
-$VERSION = "1.01";
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(yield cond_signal cond_broadcast cond_wait async);
-
-=head1 NAME
-
-Thread - manipulate threads in Perl (EXPERIMENTAL, subject to change)
-
-=head1 CAVEAT
-
-The Thread extension requires Perl to be built in a particular way to
-enable the older 5.005 threading model. Just to confuse matters, there
-is an alternate threading model known as "ithreads" that does NOT
-support this extension. If you are using a binary distribution such
-as ActivePerl that is built with ithreads support, this extension CANNOT
-be used.
-
-=head1 SYNOPSIS
-
- use Thread;
-
- my $t = new Thread \&start_sub, @start_args;
-
- $result = $t->join;
- $result = $t->eval;
- $t->detach;
- $flags = $t->flags;
-
- if ($t->done) {
- $t->join;
- }
-
- if($t->equal($another_thread)) {
- # ...
- }
-
- my $tid = Thread->self->tid;
- my $tlist = Thread->list;
-
- lock($scalar);
- yield();
-
- use Thread 'async';
-
-=head1 DESCRIPTION
-
- WARNING: Threading is an experimental feature. Both the interface
- and implementation are subject to change drastically. In fact, this
- documentation describes the flavor of threads that was in version
- 5.005. Perl 5.6.0 and later have the beginnings of support for
- interpreter threads, which (when finished) is expected to be
- significantly different from what is described here. The information
- contained here may therefore soon be obsolete. Use at your own risk!
-
-The C<Thread> module provides multithreading support for perl.
-
-=head1 FUNCTIONS
-
-=over 8
-
-=item new \&start_sub
-
-=item new \&start_sub, LIST
-
-C<new> starts a new thread of execution in the referenced subroutine. The
-optional list is passed as parameters to the subroutine. Execution
-continues in both the subroutine and the code after the C<new> call.
-
-C<new Thread> returns a thread object representing the newly created
-thread.
-
-=item lock VARIABLE
-
-C<lock> places a lock on a variable until the lock goes out of scope. If
-the variable is locked by another thread, the C<lock> call will block until
-it's available. C<lock> is recursive, so multiple calls to C<lock> are
-safe--the variable will remain locked until the outermost lock on the
-variable goes out of scope.
-
-Locks on variables only affect C<lock> calls--they do I<not> affect normal
-access to a variable. (Locks on subs are different, and covered in a bit)
-If you really, I<really> want locks to block access, then go ahead and tie
-them to something and manage this yourself. This is done on purpose. While
-managing access to variables is a good thing, perl doesn't force you out of
-its living room...
-
-If a container object, such as a hash or array, is locked, all the elements
-of that container are not locked. For example, if a thread does a C<lock
-@a>, any other thread doing a C<lock($a[12])> won't block.
-
-You may also C<lock> a sub, using C<lock &sub>. Any calls to that sub from
-another thread will block until the lock is released. This behaviour is not
-equivalent to declaring the sub with the C<locked> attribute. The C<locked>
-attribute serializes access to a subroutine, but allows different threads
-non-simultaneous access. C<lock &sub>, on the other hand, will not allow
-I<any> other thread access for the duration of the lock.
-
-Finally, C<lock> will traverse up references exactly I<one> level.
-C<lock(\$a)> is equivalent to C<lock($a)>, while C<lock(\\$a)> is not.
-
-=item async BLOCK;
-
-C<async> creates a thread to execute the block immediately following
-it. This block is treated as an anonymous sub, and so must have a
-semi-colon after the closing brace. Like C<new Thread>, C<async> returns a
-thread object.
-
-=item Thread->self
-
-The C<Thread-E<gt>self> function returns a thread object that represents
-the thread making the C<Thread-E<gt>self> call.
-
-=item Thread->list
-
-C<Thread-E<gt>list> returns a list of thread objects for all running and
-finished but un-C<join>ed threads.
-
-=item cond_wait VARIABLE
-
-The C<cond_wait> function takes a B<locked> variable as a parameter,
-unlocks the variable, and blocks until another thread does a C<cond_signal>
-or C<cond_broadcast> for that same locked variable. The variable that
-C<cond_wait> blocked on is relocked after the C<cond_wait> is satisfied.
-If there are multiple threads C<cond_wait>ing on the same variable, all but
-one will reblock waiting to reaquire the lock on the variable. (So if
-you're only using C<cond_wait> for synchronization, give up the lock as
-soon as possible)
-
-=item cond_signal VARIABLE
-
-The C<cond_signal> function takes a locked variable as a parameter and
-unblocks one thread that's C<cond_wait>ing on that variable. If more than
-one thread is blocked in a C<cond_wait> on that variable, only one (and
-which one is indeterminate) will be unblocked.
-
-If there are no threads blocked in a C<cond_wait> on the variable, the
-signal is discarded.
-
-=item cond_broadcast VARIABLE
-
-The C<cond_broadcast> function works similarly to C<cond_signal>.
-C<cond_broadcast>, though, will unblock B<all> the threads that are blocked
-in a C<cond_wait> on the locked variable, rather than only one.
-
-=item yield
-
-The C<yield> function allows another thread to take control of the
-CPU. The exact results are implementation-dependent.
-
-=back
-
-=head1 METHODS
-
-=over 8
-
-=item join
-
-C<join> waits for a thread to end and returns any values the thread exited
-with. C<join> will block until the thread has ended, though it won't block
-if the thread has already terminated.
-
-If the thread being C<join>ed C<die>d, the error it died with will be
-returned at this time. If you don't want the thread performing the C<join>
-to die as well, you should either wrap the C<join> in an C<eval> or use the
-C<eval> thread method instead of C<join>.
-
-=item eval
-
-The C<eval> method wraps an C<eval> around a C<join>, and so waits for a
-thread to exit, passing along any values the thread might have returned.
-Errors, of course, get placed into C<$@>.
-
-=item detach
-
-C<detach> tells a thread that it is never going to be joined i.e.
-that all traces of its existence can be removed once it stops running.
-Errors in detached threads will not be visible anywhere - if you want
-to catch them, you should use $SIG{__DIE__} or something like that.
-
-=item equal
-
-C<equal> tests whether two thread objects represent the same thread and
-returns true if they do.
-
-=item tid
-
-The C<tid> method returns the tid of a thread. The tid is a monotonically
-increasing integer assigned when a thread is created. The main thread of a
-program will have a tid of zero, while subsequent threads will have tids
-assigned starting with one.
-
-=item flags
-
-The C<flags> method returns the flags for the thread. This is the
-integer value corresponding to the internal flags for the thread, and
-the value may not be all that meaningful to you.
-
-=item done
-
-The C<done> method returns true if the thread you're checking has
-finished, and false otherwise.
-
-=back
-
-=head1 LIMITATIONS
-
-The sequence number used to assign tids is a simple integer, and no
-checking is done to make sure the tid isn't currently in use. If a program
-creates more than 2^32 - 1 threads in a single run, threads may be assigned
-duplicate tids. This limitation may be lifted in a future version of Perl.
-
-=head1 SEE ALSO
-
-L<attributes>, L<Thread::Queue>, L<Thread::Semaphore>, L<Thread::Specific>.
-
-=cut
-
-#
-# Methods
-#
-
-#
-# Exported functions
-#
-sub async (&) {
- return new Thread $_[0];
-}
-
-sub eval {
- return eval { shift->join; };
-}
-
-XSLoader::load 'Thread';
-
-1;
diff --git a/ext/Thread/create.tx b/ext/Thread/create.tx
index 7cc8334eb4..13f3852f82 100644
--- a/ext/Thread/create.tx
+++ b/ext/Thread/create.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread 'async';
diff --git a/ext/Thread/die.tx b/ext/Thread/die.tx
index 1a65f1413b..25814162da 100644
--- a/ext/Thread/die.tx
+++ b/ext/Thread/die.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread 'async';
diff --git a/ext/Thread/die2.tx b/ext/Thread/die2.tx
index 4bc611a321..d84b3d015f 100644
--- a/ext/Thread/die2.tx
+++ b/ext/Thread/die2.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread 'async';
diff --git a/ext/Thread/io.tx b/ext/Thread/io.tx
index 693d91067d..8855897a9b 100644
--- a/ext/Thread/io.tx
+++ b/ext/Thread/io.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/join.tx b/ext/Thread/join.tx
index d24473f2a0..db9e21989e 100644
--- a/ext/Thread/join.tx
+++ b/ext/Thread/join.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/join2.tx b/ext/Thread/join2.tx
index 04f244d02c..c7d5e1500f 100644
--- a/ext/Thread/join2.tx
+++ b/ext/Thread/join2.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/list.tx b/ext/Thread/list.tx
index f03fa06c18..424b46f22a 100644
--- a/ext/Thread/list.tx
+++ b/ext/Thread/list.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread qw(async);
diff --git a/ext/Thread/lock.tx b/ext/Thread/lock.tx
index b8887878a0..d8199b59d8 100644
--- a/ext/Thread/lock.tx
+++ b/ext/Thread/lock.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/queue.tx b/ext/Thread/queue.tx
index 5c1a7e763d..de3a895d25 100644
--- a/ext/Thread/queue.tx
+++ b/ext/Thread/queue.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/specific.tx b/ext/Thread/specific.tx
index c2bf1a15d0..4747b6acf9 100644
--- a/ext/Thread/specific.tx
+++ b/ext/Thread/specific.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/sync.tx b/ext/Thread/sync.tx
index c5cf1a754f..4fa25a7a8f 100644
--- a/ext/Thread/sync.tx
+++ b/ext/Thread/sync.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/sync2.tx b/ext/Thread/sync2.tx
index ace0cbdfe7..7311231989 100644
--- a/ext/Thread/sync2.tx
+++ b/ext/Thread/sync2.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/unsync.tx b/ext/Thread/unsync.tx
index 51faa8c24b..b4adb3b67c 100644
--- a/ext/Thread/unsync.tx
+++ b/ext/Thread/unsync.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/unsync2.tx b/ext/Thread/unsync2.tx
index 0016646447..15765373dc 100644
--- a/ext/Thread/unsync2.tx
+++ b/ext/Thread/unsync2.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/unsync3.tx b/ext/Thread/unsync3.tx
index a1d2c56d39..ecf77d1b04 100644
--- a/ext/Thread/unsync3.tx
+++ b/ext/Thread/unsync3.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;
diff --git a/ext/Thread/unsync4.tx b/ext/Thread/unsync4.tx
index 1186fc030f..8a6c1241d7 100644
--- a/ext/Thread/unsync4.tx
+++ b/ext/Thread/unsync4.tx
@@ -4,10 +4,6 @@ BEGIN {
print "1..0 # Skip: no Config\n";
exit(0);
}
- if ($Config{extensions} !~ /\bThread\b/) {
- print "1..0 # Skip: no use5005threads\n";
- exit(0);
- }
}
use Thread;