r33205 - in /branches/upstream/libthread-queue-any-perl: ./ current/ current/lib/ current/lib/Thread/ current/lib/Thread/Queue/ current/t/
mzagrabe-guest at users.alioth.debian.org
mzagrabe-guest at users.alioth.debian.org
Tue Apr 14 17:55:57 UTC 2009
Author: mzagrabe-guest
Date: Tue Apr 14 17:55:51 2009
New Revision: 33205
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33205
Log:
[svn-inject] Installing original source of libthread-queue-any-perl
Added:
branches/upstream/libthread-queue-any-perl/
branches/upstream/libthread-queue-any-perl/current/
branches/upstream/libthread-queue-any-perl/current/CHANGELOG
branches/upstream/libthread-queue-any-perl/current/MANIFEST
branches/upstream/libthread-queue-any-perl/current/META.yml
branches/upstream/libthread-queue-any-perl/current/Makefile.PL
branches/upstream/libthread-queue-any-perl/current/README
branches/upstream/libthread-queue-any-perl/current/TODO
branches/upstream/libthread-queue-any-perl/current/VERSION
branches/upstream/libthread-queue-any-perl/current/lib/
branches/upstream/libthread-queue-any-perl/current/lib/Thread/
branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/
branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/Any.pm
branches/upstream/libthread-queue-any-perl/current/t/
branches/upstream/libthread-queue-any-perl/current/t/Queue-Any.t
Added: branches/upstream/libthread-queue-any-perl/current/CHANGELOG
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/CHANGELOG?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/CHANGELOG (added)
+++ branches/upstream/libthread-queue-any-perl/current/CHANGELOG Tue Apr 14 17:55:51 2009
@@ -1,0 +1,47 @@
+0.09 3 October 2007
+ Hopefully fixed test-suite for none thread enabled Perls.
+
+0.08 3 August 2007
+ Added version markers so that there will be no complaining if
+ Devel::Required is installed. Otherwise same as 0.07.
+
+0.07 28 December 2003
+ Added automatic required modules update using Devel::Required.
+
+0.06 13 August 2003
+ Cleaned up Makefile.PL and updated copyright info. Made sure the
+ test-suite runs ok with warnings enabled.
+
+ Removed our and ":unique" attribute as with all of my other Thread::xxx
+ modules.
+
+0.05 24 July 2002
+ Made $VERSION and @ISA have the : unique attribute to save memory.
+
+ Added method "dequeue_keep" plus documentation and test-suite.
+
+0.04 21 July 2002
+ Added "can_ok" check to the test-suite.
+
+ Renamed "dequeue_nb" to "dequeue_dontwait" to be more in line with
+ Thread::Pool. Added "dequeue_nb" as synonym to remain compatible
+ with Thread::Queue.
+
+ Fixed several documentation nits.
+
+0.03 14 July 2002
+ Added -use threads- to Makefile.PL to cause breakage if attempting
+ to install on a system without threads.
+
+ Added Perl version requirement to README and pod per suggestion of
+ mrbbking.
+
+0.02 13 July 2002
+ Added copyright info to pod.
+
+ Name change threads::shared:: -> Thread:: caused this module to be
+ renamed to Thread::Queue::Any. And all the other changes that were
+ necessary.
+
+0.01 10 July 2002
+ First version of threads::shared::queue::any.
Added: branches/upstream/libthread-queue-any-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/MANIFEST?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/MANIFEST (added)
+++ branches/upstream/libthread-queue-any-perl/current/MANIFEST Tue Apr 14 17:55:51 2009
@@ -1,0 +1,9 @@
+MANIFEST
+CHANGELOG
+README
+TODO
+VERSION
+Makefile.PL
+lib/Thread/Queue/Any.pm
+t/Queue-Any.t
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libthread-queue-any-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/META.yml?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/META.yml (added)
+++ branches/upstream/libthread-queue-any-perl/current/META.yml Tue Apr 14 17:55:51 2009
@@ -1,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Thread-Queue-Any
+version: 0.09
+version_from: lib/Thread/Queue/Any.pm
+installdirs: site
+requires:
+ Storable: 0
+ Thread::Queue: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: branches/upstream/libthread-queue-any-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/Makefile.PL?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/Makefile.PL (added)
+++ branches/upstream/libthread-queue-any-perl/current/Makefile.PL Tue Apr 14 17:55:51 2009
@@ -1,0 +1,33 @@
+require 5.008;
+
+# do we have threads?
+my $module;
+BEGIN {
+ $module = "Thread::Queue::Any";
+
+ require Config;
+ Config->import;
+
+ if ( !$Config{useithreads} ) {
+ print "$module requires a version of perl that has threads enabled.\n";
+ exit 0;
+ }
+}
+
+# set up stuff
+use ExtUtils::MakeMaker;
+
+# set version and dependency info
+eval "use Devel::Required";
+
+# set up
+WriteMakefile (
+ NAME => $module,
+ AUTHOR => 'Elizabeth Mattijsen (liz at dijkmat.nl)',
+ ABSTRACT => 'thread-safe queues for any data-structure',
+ VERSION_FROM => 'lib/Thread/Queue/Any.pm',
+ PREREQ_PM => {
+ 'Thread::Queue' => 0,
+ 'Storable' => 0,
+ },
+);
Added: branches/upstream/libthread-queue-any-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/README?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/README (added)
+++ branches/upstream/libthread-queue-any-perl/current/README Tue Apr 14 17:55:51 2009
@@ -1,0 +1,28 @@
+README for Thread::Queue::Any
+
+Almost drop-in replacement for Thread::Queue that allows any (unshared)
+data-structure to be passed between threads by means of a queue.
+
+ *** A note of CAUTION ***
+
+This module only functions on Perl versions 5.8.0-RC3 and later. And then
+only when threads are enabled with -Dusethreads. It is of no use with any
+version of Perl before 5.8.0-RC3 or without threads enabled.
+
+ *************************
+
+Copyright (c) 2002,2003,2007 Elizabeth Mattijsen <liz at dijkmat.nl>. All rights
+reserved. This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+Version:
+ 0.09
+
+Required Modules:
+ Storable (any)
+ Thread::Queue (any)
+
+perl Makefile.PL
+make
+make test
+make install
Added: branches/upstream/libthread-queue-any-perl/current/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/TODO?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/TODO (added)
+++ branches/upstream/libthread-queue-any-perl/current/TODO Tue Apr 14 17:55:51 2009
@@ -1,0 +1,2 @@
+Check out whether Data::Dumper as an alternate way to safely serialize data
+(including code refs) between threads, as per suggestion of Brent Dax.
Added: branches/upstream/libthread-queue-any-perl/current/VERSION
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/VERSION?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/VERSION (added)
+++ branches/upstream/libthread-queue-any-perl/current/VERSION Tue Apr 14 17:55:51 2009
@@ -1,0 +1,1 @@
+0.09
Added: branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/Any.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/Any.pm?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/Any.pm (added)
+++ branches/upstream/libthread-queue-any-perl/current/lib/Thread/Queue/Any.pm Tue Apr 14 17:55:51 2009
@@ -1,0 +1,190 @@
+package Thread::Queue::Any;
+
+# Make sure we inherit from Thread::Queue
+# Make sure we have version info for this module
+# Make sure we do everything by the book from now on
+
+ at ISA = qw(Thread::Queue);
+$VERSION = '0.09';
+use strict;
+
+# Make sure we have Storable
+# Make sure we have queues
+
+use Storable (); # no need to pollute namespace
+use Thread::Queue (); # no need to pollute namespace
+
+# Allow for synonym for dequeue_dontwait
+
+*dequeue_nb = \&dequeue_dontwait;
+
+# Satisfy -require-
+
+1;
+
+#---------------------------------------------------------------------------
+# IN: 1 instantiated object
+# 2..N parameters to be passed as a set onto the queue
+
+sub enqueue {
+ shift->SUPER::enqueue( Storable::freeze( \@_ ) );
+}
+
+#---------------------------------------------------------------------------
+# IN: 1 instantiated object
+# OUT: 1..N parameters returned from a set on the queue
+
+sub dequeue {
+ @{Storable::thaw( shift->SUPER::dequeue )};
+}
+
+#---------------------------------------------------------------------------
+# IN: 1 instantiated object
+# OUT: 1..N parameters returned from a set on the queue
+
+sub dequeue_dontwait {
+ return unless my $ref = shift->SUPER::dequeue_nb;
+ @{Storable::thaw( $ref )};
+}
+
+#---------------------------------------------------------------------------
+# IN: 1 instantiated object
+# OUT: 1..N parameters returned from a set on the queue
+
+sub dequeue_keep {
+# return unless my $ref = shift->SUPER::dequeue_keep; # doesn't exist yet
+ return unless my $ref = shift->[0]; # temporary
+ @{Storable::thaw( $ref )};
+}
+
+#---------------------------------------------------------------------------
+
+__END__
+
+=head1 NAME
+
+Thread::Queue::Any - thread-safe queues for any data-structure
+
+=head1 SYNOPSIS
+
+ use Thread::Queue::Any;
+ my $q = Thread::Queue::Any->new;
+ $q->enqueue("foo", ["bar"], {"zoo"});
+ my ($foo,$bar,$zoo) = $q->dequeue;
+ my ($foo,$bar,$zoo) = $q->dequeue_dontwait;
+ my ($iffoo,$ifbar,$ifzoo) = $q->dequeue_keep;
+ my $left = $q->pending;
+
+=head1 VERSION
+
+This documentation describes version 0.09.
+
+=head1 DESCRIPTION
+
+ *** A note of CAUTION ***
+
+ This module only functions on Perl versions 5.8.0-RC3 and later.
+ And then only when threads are enabled with -Dusethreads. It is
+ of no use with any version of Perl before 5.8.0-RC3 or without
+ threads enabled.
+
+ *************************
+
+A queue, as implemented by C<Thread::Queue::Any> is a thread-safe
+data structure that inherits from C<Thread::Queue>. But unlike the
+standard C<Thread::Queue>, you can pass (a reference to) any data
+structure to the queue.
+
+Apart from the fact that the parameters to C<enqueue> are considered to be
+a set that needs to be enqueued together and that C<dequeue> returns all of
+the parameters that were enqueued together, this module is a drop-in
+replacement for C<Thread::Queue> in every other aspect.
+
+Any number of threads can safely add elements to the end of the list, or
+remove elements from the head of the list. (Queues don't permit adding or
+removing elements from the middle of the list).
+
+=head1 CLASS METHODS
+
+=head2 new
+
+ $queue = Thread::Queue::Any->new;
+
+The C<new> function creates a new empty queue.
+
+=head1 OBJECT METHODS
+
+=head2 enqueue LIST
+
+ $queue->enqueue( 'string',$scalar,[],{} );
+
+The C<enqueue> method adds a reference to all the specified parameters on to
+the end of the queue. The queue will grow as needed.
+
+=head2 dequeue
+
+ ($string,$scalar,$listref,$hashref) = $queue->dequeue;
+
+The C<dequeue> method removes a reference from the head of the queue,
+dereferences it and returns the resulting values. If the queue is currently
+empty, C<dequeue> will block the thread until another thread C<enqueue>s.
+
+=head2 dequeue_dontwait
+
+ ($string,$scalar,$listref,$hashref) = $queue->dequeue_dontwait;
+
+The C<dequeue_dontwait> method, like the C<dequeue> method, removes a
+reference from the head of the queue, dereferences it and returns the
+resulting values. Unlike C<dequeue>, though, C<dequeue_dontwait> won't wait
+if the queue is empty, instead returning an empty list if the queue is empty.
+
+For compatibility with L<Thread::Queue>, the name "dequeue_nb" is available
+as a synonym for this method.
+
+=head2 dequeue_keep
+
+ ($string,$scalar,$listref,$hashref) = $queue->dequeue_keep;
+
+The C<dequeue_keep> method, like the C<dequeue_dontwait> method, takes a
+reference from the head of the queue, dereferences it and returns the
+resulting values. Unlike C<dequeue_dontwait>, though, the C<dequeue_keep>
+B<won't remove> the set from the queue. It can therefore be used to test if
+the next set to be returned from the queue with C<dequeue> or
+C<dequeue_dontwait> will have a specific value.
+
+=head2 pending
+
+ $pending = $queue->pending;
+
+The C<pending> method returns the number of items still in the queue.
+
+=head1 REQUIRED MODULES
+
+ Storable (any)
+ Thread::Queue (any)
+
+=head1 CAVEATS
+
+Passing unshared values between threads is accomplished by serializing the
+specified values using C<Storable> when enqueuing and de-serializing the queued
+value on dequeuing. This allows for great flexibility at the expense of more
+CPU usage. It also limits what can be passed, as e.g. code references can
+B<not> be serialized and therefore not be passed.
+
+=head1 AUTHOR
+
+Elizabeth Mattijsen, <liz at dijkmat.nl>.
+
+Please report bugs to <perlbugs at dijkmat.nl>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2002 - 2007 Elizabeth Mattijsen <liz at dijkmat.nl>. All rights
+reserved. This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<threads>, L<threads::shared>, L<Thread::Queue>, L<Storable>.
+
+=cut
Added: branches/upstream/libthread-queue-any-perl/current/t/Queue-Any.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-queue-any-perl/current/t/Queue-Any.t?rev=33205&op=file
==============================================================================
--- branches/upstream/libthread-queue-any-perl/current/t/Queue-Any.t (added)
+++ branches/upstream/libthread-queue-any-perl/current/t/Queue-Any.t Tue Apr 14 17:55:51 2009
@@ -1,0 +1,58 @@
+BEGIN { # Magic Perl CORE pragma
+ if ($ENV{PERL_CORE}) {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ }
+}
+
+use strict;
+use warnings;
+use Test::More tests => 16;
+
+BEGIN { use_ok('threads') }
+BEGIN { use_ok('Thread::Queue::Any') }
+
+my $q = Thread::Queue::Any->new;
+isa_ok( $q, 'Thread::Queue::Any', 'check object type' );
+can_ok( $q,qw(
+ dequeue
+ dequeue_dontwait
+ dequeue_keep
+ dequeue_nb
+ enqueue
+ new
+ pending
+) );
+
+$q->enqueue( qw(a b c) );
+$q->enqueue( [qw(a b c)] );
+$q->enqueue( {a => 1, b => 2, c => 3} );
+
+is( $q->pending, 3, 'check number pending');
+
+my @l = $q->dequeue;
+is( @l, 3, 'check # elements simple list' );
+ok( ($l[0] eq 'a' and $l[1] eq 'b' and $l[2] eq 'c'), 'check simple list' );
+
+my @lr = $q->dequeue_nb;
+cmp_ok( @lr, '==', 1, 'check # elements list ref' );
+is( ref($lr[0]), 'ARRAY', 'check type of list ref' );
+ok(
+ ($lr[0]->[0] eq 'a' and $lr[0]->[1] eq 'b' and $lr[0]->[2] eq 'c'),
+ 'check list ref'
+);
+
+my @hr = $q->dequeue_keep;
+cmp_ok( @hr, '==', 1, 'check # elements hash ref, #1' );
+is( ref($hr[0]), 'HASH', 'check type of hash ref, #1' );
+
+ at hr = $q->dequeue;
+cmp_ok( @hr, '==', 1, 'check # elements hash ref, #2' );
+is( ref($hr[0]), 'HASH', 'check type of hash ref, #2' );
+ok(
+ ($hr[0]->{a} == 1 and $hr[0]->{b} == 2 and $hr[0]->{c} == 3),
+ 'check hash ref'
+);
+
+my @e = $q->dequeue_dontwait;
+cmp_ok( @e, '==', 0, 'check # elements non blocking' );
More information about the Pkg-perl-cvs-commits
mailing list