source: trunk/essentials/dev-lang/perl/ext/Thread/Queue.pmx

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 2.5 KB
Line 
1package Thread::Queue;
2use Thread qw(cond_wait cond_broadcast);
3
4use vars qw($VERSION);
5$VERSION = '1.00';
6
7=head1 NAME
8
9Thread::Queue - thread-safe queues (5.005-threads)
10
11=head1 CAVEAT
12
13This Perl installation is using the old unsupported "5.005 threads".
14Use of the old threads model is discouraged.
15
16For the whole story about the development of threads in Perl, and why
17you should B<not> be using "old threads" unless you know what you're
18doing, see the CAVEAT of the C<Thread> module.
19
20=head1 SYNOPSIS
21
22 use Thread::Queue;
23 my $q = new Thread::Queue;
24 $q->enqueue("foo", "bar");
25 my $foo = $q->dequeue; # The "bar" is still in the queue.
26 my $foo = $q->dequeue_nb; # returns "bar", or undef if the queue was
27 # empty
28 my $left = $q->pending; # returns the number of items still in the queue
29
30=head1 DESCRIPTION
31
32A queue, as implemented by C<Thread::Queue> is a thread-safe data structure
33much like a list. Any number of threads can safely add elements to the end
34of the list, or remove elements from the head of the list. (Queues don't