r33200 - in /branches/upstream/libthread-serialize-perl: ./ current/ current/lib/ current/lib/Thread/ current/t/
mzagrabe-guest at users.alioth.debian.org
mzagrabe-guest at users.alioth.debian.org
Tue Apr 14 17:54:03 UTC 2009
Author: mzagrabe-guest
Date: Tue Apr 14 17:53:58 2009
New Revision: 33200
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33200
Log:
[svn-inject] Installing original source of libthread-serialize-perl
Added:
branches/upstream/libthread-serialize-perl/
branches/upstream/libthread-serialize-perl/current/
branches/upstream/libthread-serialize-perl/current/CHANGELOG
branches/upstream/libthread-serialize-perl/current/MANIFEST
branches/upstream/libthread-serialize-perl/current/META.yml
branches/upstream/libthread-serialize-perl/current/Makefile.PL
branches/upstream/libthread-serialize-perl/current/README
branches/upstream/libthread-serialize-perl/current/TODO
branches/upstream/libthread-serialize-perl/current/VERSION
branches/upstream/libthread-serialize-perl/current/lib/
branches/upstream/libthread-serialize-perl/current/lib/Thread/
branches/upstream/libthread-serialize-perl/current/lib/Thread/Serialize.pm
branches/upstream/libthread-serialize-perl/current/t/
branches/upstream/libthread-serialize-perl/current/t/Serialize.t
Added: branches/upstream/libthread-serialize-perl/current/CHANGELOG
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/CHANGELOG?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/CHANGELOG (added)
+++ branches/upstream/libthread-serialize-perl/current/CHANGELOG Tue Apr 14 17:53:58 2009
@@ -1,0 +1,55 @@
+0.10 29 September 2004
+ Added support for $Thread::Serialize::no_external_perl to prevent
+ problems when used in embedded Perls. Spotted by Philip Monsen.
+ Added documentation and additional tests in the test-suite.
+
+0.09 28 December 2003
+ Added automatic required modules update using Devel::Required.
+
+0.08 18 September 2003
+ Upgraded dependency on load to 0.10, since that has some significant
+ Windows fixes.
+
+0.07 17 September 2003
+ Upgraded dependency on load to 0.09.
+
+ 17 August 2003
+ Some documentation fixes: we're not using AutoLoader anymore.
+
+0.06 11 August 2003
+ Fixed some nits in Makefile.PL. Updated copyright notice.
+
+ Fixed dependency on order of hash keys in test-suite: this caused
+ spurious testing errors in 5.8.1.
+
+0.05 30 September 2002
+ Removed support for AutoLoader and replaced it by support for "load.pm".
+ Added dependency on "load" to Makefile.PL.
+
+ Removed "our" from $VERSION, should shave off some bytes in memory
+ usage, as found from testing with Benchmark::Thread::Size.
+
+0.04 22 September 2002
+ Fixed warnings when running under -w. Thanks to Chris Rosebrugh for
+ the spot.
+
+0.03 10 September 2002
+ Removed the NOT_ICED environment variable hack and its documentation.
+ Replaced by having an external Perl process calculate the Storable
+ (iced) signature at load time. This should be compatible with all
+ versions of Storable on all possible OS's and hardware architectures.
+
+0.02 30 August 2002
+ Now uses pre-frozen signature value unless told otherwise. This saves
+ Storable::freeze to have to be available in all threads. Can be
+ circumvented by specifying NOT_ICED environment variable. Added
+ OPTIMIZATIONS and CAVEATS sections to the pod.
+
+ Added support for AutoLoader. Together with all of the other Thread::
+ modules, this should start saving a lot of memory.
+
+ Removed reference tricks: we should find other ways of saving memory
+ with threads.
+
+0.01 13 August 2002
+ First version of Thread::Serialize.
Added: branches/upstream/libthread-serialize-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/MANIFEST?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/MANIFEST (added)
+++ branches/upstream/libthread-serialize-perl/current/MANIFEST Tue Apr 14 17:53:58 2009
@@ -1,0 +1,9 @@
+MANIFEST
+CHANGELOG
+README
+TODO
+VERSION
+Makefile.PL
+lib/Thread/Serialize.pm
+t/Serialize.t
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libthread-serialize-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/META.yml?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/META.yml (added)
+++ branches/upstream/libthread-serialize-perl/current/META.yml Tue Apr 14 17:53:58 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-Serialize
+version: 0.10
+version_from: lib/Thread/Serialize.pm
+installdirs: site
+requires:
+ load: 0.10
+ Storable: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: branches/upstream/libthread-serialize-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/Makefile.PL?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/Makefile.PL (added)
+++ branches/upstream/libthread-serialize-perl/current/Makefile.PL Tue Apr 14 17:53:58 2009
@@ -1,0 +1,15 @@
+require 5.008;
+use threads (); # just to force breakage if threads are not available
+use ExtUtils::MakeMaker;
+eval "use Devel::Required";
+
+WriteMakefile (
+ NAME => "Thread::Serialize",
+ AUTHOR => 'Elizabeth Mattijsen (liz at dijkmat.nl)',
+ ABSTRACT => 'serialize data-structures between threads',
+ VERSION_FROM => 'lib/Thread/Serialize.pm',
+ PREREQ_PM => {
+ 'load' => '0.10',
+ 'Storable' => 0,
+ },
+);
Added: branches/upstream/libthread-serialize-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/README?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/README (added)
+++ branches/upstream/libthread-serialize-perl/current/README Tue Apr 14 17:53:58 2009
@@ -1,0 +1,26 @@
+README for Thread::Serialize
+
+Library for data-structure serialization between threads.
+
+ *** A note of CAUTION ***
+
+This module only functions on Perl versions 5.8.0 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 or without threads enabled.
+
+ *************************
+
+Copyright (c) 2002-2003 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.
+
+Required Modules:
+ load (0.10)
+ Storable (any)
+
+The build is standard:
+
+perl Makefile.PL
+make
+make test
+make install
Added: branches/upstream/libthread-serialize-perl/current/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/TODO?rev=33200&op=file
==============================================================================
(empty)
Added: branches/upstream/libthread-serialize-perl/current/VERSION
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/VERSION?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/VERSION (added)
+++ branches/upstream/libthread-serialize-perl/current/VERSION Tue Apr 14 17:53:58 2009
@@ -1,0 +1,1 @@
+0.10
Added: branches/upstream/libthread-serialize-perl/current/lib/Thread/Serialize.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/lib/Thread/Serialize.pm?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/lib/Thread/Serialize.pm (added)
+++ branches/upstream/libthread-serialize-perl/current/lib/Thread/Serialize.pm Tue Apr 14 17:53:58 2009
@@ -1,0 +1,227 @@
+package Thread::Serialize;
+
+# Make sure we have version info for this module
+# Make sure we do everything by the book from now on
+
+$VERSION = '0.10';
+use strict;
+
+# Make sure we only load things that we need when we need it
+
+use load;
+
+# Make sure we can freeze and thaw
+
+use Storable ();
+
+# Initialize Storable signature
+# If we should not use an external Perl to determine signature
+# Use local copy of routines, causing AutoLoader to load lot's of stuff
+# Else
+# Execute external perl to obtain Storable signature (saves memory here)
+
+our $iced;
+if ($Thread::Serialize::no_external_perl) {
+ $iced = unpack( 'l',Storable::freeze( [] ));
+ $Thread::Serialize::no_external_perl = 'Signature obtained locally';
+} else {
+ open( my $handle,
+ qq($^X -MStorable -e "print unpack('l',Storable::freeze( [] ))" | )
+ ) or die "Cannot determine Storable signature\n";
+ $iced = <$handle>;
+}
+
+# Satisfy -require-
+
+1;
+
+# The following subroutines are loaded on demand only
+
+__END__
+
+#---------------------------------------------------------------------------
+# IN: 1..N parameters to freeze
+# OUT: 1 frozen scalar
+
+sub freeze {
+
+# If we have at least one element in the list
+# For all of the elements
+# Return truly frozen version if something special
+# Return the values contatenated with null bytes
+# Else (empty list)
+# Return undef value
+
+ if (@_) {
+ foreach (@_) {
+ return Storable::freeze( \@_ ) if !defined() or ref() or m#\0#;
+ }
+ return join( "\0", at _ );
+ } else {
+ return;
+ }
+} #freeze
+
+#---------------------------------------------------------------------------
+# IN: 1 frozen scalar to defrost
+# OUT: 1..N thawed data structure
+
+sub thaw {
+
+# Return now if nothing to return or not interested in result
+
+ return unless defined( $_[0] ) and defined( wantarray );
+
+# If we're interested in a list
+# Return thawed list from frozen info if frozen
+# Return list split from a normal string
+# Elseif we have frozen stuff (and we want a scalar)
+# Thaw the list and return the first element
+# Else (not frozen and we want a scalar)
+# Look for the first nullbyte and return string until then if found
+# Return the string
+
+ if (wantarray) {
+ return @{Storable::thaw( $_[0] )} if (unpack( 'l',$_[0] )||0) == $iced;
+ split( "\0",$_[0] )
+ } elsif ((unpack( 'l',$_[0] )||0) == $iced) {
+ Storable::thaw( $_[0] )->[0];
+ } else {
+ return $1 if $_[0] =~ m#^([^\0]*)#;
+ $_[0];
+ }
+} #thaw
+
+#---------------------------------------------------------------------------
+
+# standard Perl features
+
+#---------------------------------------------------------------------------
+
+sub import {
+
+# Lose the class
+# Obtain the namespace
+# Obtain the names of the subroutines to export
+# Allow for dirty tricks
+# Export all subroutines specified
+
+ shift;
+ my $namespace = caller().'::';
+ @_ = qw(freeze thaw) unless @_;
+ no strict 'refs';
+ *{$namespace.$_} = \&$_ foreach @_;
+} #import
+
+#---------------------------------------------------------------------------
+
+__END__
+
+=head1 NAME
+
+Thread::Serialize - serialize data-structures between threads
+
+=head1 SYNOPSIS
+
+ use Thread::Serialize; # export freeze() and thaw()
+
+ use Thread::Serialize (); # must call fully qualified subs
+
+ my $frozen = freeze( any data structure );
+ any data structure = thaw( $frozen );
+
+=head1 DESCRIPTION
+
+ *** A note of CAUTION ***
+
+ This module only functions on Perl versions 5.8.0 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 or without
+ threads enabled.
+
+ *************************
+
+The Thread::Serialize module is a library for centralizing the routines
+used to serialize data-structures between threads. Because of this central
+location, other modules such as L<Thread::Conveyor>, L<Thread::Pool> or
+L<Thread::Tie> can benefit from the same optimilizations that may take
+place here in the future.
+
+=head1 SUBROUTINES
+
+There are only two subroutines.
+
+=head2 freeze
+
+ my $frozen = freeze( $scalar );
+
+ my $frozen = freeze( @array );
+
+The "freeze" subroutine takes all the parameters passed to it, freezes them
+and returns a frozen representation of what was given. The parameters can
+be scalar values or references to arrays or hashes. Use the L<thaw>
+subroutine to obtain the original data-structure back.
+
+=head2 thaw
+
+ my $scalar = thaw( $frozen );
+
+ my @array = thaw( $frozen );
+
+The "thaw" subroutine returns the data-structure that was frozen with a call
+to L<freeze>. If called in a scalar context, only the first element of the
+data-structure that was passed, will be returned. Otherwise the entire
+data-structure will be returned.
+
+It is up to the developer to make sure that single argument calls to L<freeze>
+are always matched by scalar context calls to L<thaw>.
+
+=head1 REQUIRED MODULES
+
+ load (0.10)
+ Storable (any)
+
+=head1 OPTIMIZATIONS
+
+To reduce memory and CPU usage, this module uses L<load>. This causes
+subroutines only to be compiled in a thread when they are actually needed at
+the expense of more CPU when they need to be compiled. Simple benchmarks
+however revealed that the overhead of the compiling single routines is not
+much more (and sometimes a lot less) than the overhead of cloning a Perl
+interpreter with a lot of subroutines pre-loaded.
+
+To reduce the number of modules and subroutines loaded, an external Perl
+interpreter is started to determine the Storable signature at compile time.
+In some situations this may cause a problem: please set the
+C<$Thread::Serialize::no_external_perl> variable to a true value at compile
+time B<before> loading Thread::Serialize if this causes a problem.
+
+ BEGIN { $Thread::Serialize::no_external_perl = 1 }
+ use Thread::Serialize;
+
+=head1 KNOWN ISSUES
+
+=head2 Embedded Perls
+
+Philip Monsen reported that in the case of an embedded Perl interpreter (e.g.
+in a C program), the use of an external executor to determine the Storable
+signature, causes problems. This has been fixed by introducing the global
+variable C<$Thread::Serialize::no_external_perl> (see L<OPTIMIZATIONS>).
+
+=head1 AUTHOR
+
+Elizabeth Mattijsen, <liz at dijkmat.nl>.
+
+Please report bugs to <perlbugs at dijkmat.nl>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2002-2004 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<load>, L<Thread::Conveyor>, L<Thread::Pool>, L<Thread::Tie>.
+
+=cut
Added: branches/upstream/libthread-serialize-perl/current/t/Serialize.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libthread-serialize-perl/current/t/Serialize.t?rev=33200&op=file
==============================================================================
--- branches/upstream/libthread-serialize-perl/current/t/Serialize.t (added)
+++ branches/upstream/libthread-serialize-perl/current/t/Serialize.t Tue Apr 14 17:53:58 2009
@@ -1,0 +1,50 @@
+BEGIN { # Magic Perl CORE pragma
+ if ($ENV{PERL_CORE}) {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ }
+}
+
+use Test::More tests => 16;
+
+use Thread::Serialize; # can't fake bare import call yet with Test::More
+use_ok( 'Thread::Serialize' );
+can_ok( 'Thread::Serialize',qw(
+ freeze
+ thaw
+) );
+ok( !defined( $Thread::Serialize::no_external_perl ),
+ "Check flag being unset" );
+
+test();
+
+delete $INC{'Thread/Serialize.pm'};
+$Thread::Serialize::no_external_perl = 1;
+require Thread::Serialize;
+is( $Thread::Serialize::no_external_perl,'Signature obtained locally',
+ "Check flag being set and changed" );
+
+test();
+
+sub test {
+ my $scalar = '1234';
+ my $frozen = freeze( $scalar );
+ is( thaw($frozen),$scalar, 'check contents' );
+
+ my @array = qw(a b c);
+ $frozen = freeze( @array );
+ is( join('',thaw($frozen)),join('', at array), 'check contents' );
+
+ $frozen = freeze( \@array );
+ is( join('',@{thaw($frozen)}),join('', at array), 'check contents' );
+
+ $frozen = freeze();
+ is( join('',thaw($frozen)),'', 'check contents' );
+
+ $frozen = freeze( undef );
+ ok( !defined( thaw($frozen) ), 'check contents' );
+
+ my %hash = (a => 'A', b => 'B', c => 'C');
+ $frozen = freeze( \%hash );
+ is( join('',sort %{thaw($frozen)}),join('',sort %hash),'check contents' );
+} #test
More information about the Pkg-perl-cvs-commits
mailing list