# # - Thread::Use - # This spec file was automatically generated by cpan2rpm [ver: 2.028] # The following arguments were used: # --keep-pipes Thread::Use 2>&1 # For more information on cpan2rpm please visit: http://perl.arix.com/ # %define pkgname Thread-Use %define filelist %{pkgname}-%{version}-filelist %define NVR %{pkgname}-%{version}-%{release} %define maketest 1 name: perl-Thread-Use summary: Thread-Use - use a module inside a thread only version: 0.05 release: 1 vendor: Elizabeth Mattijsen (liz@dijkmat.nl) packager: Arix International license: Artistic group: Applications/CPAN url: http://www.cpan.org buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) buildarch: noarch prefix: %(echo %{_prefix}) source: http://search.cpan.org//CPAN/authors/id/E/EL/ELIZABETH/Thread-Use-0.05.tar.gz %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. ************************* When you are programming threaded applications and are interested in saving memory by selectively loading modules inside threads only, you will find that even if you `use' a module inside a thread, it is in fact available to all threads, including the main thread. This is caused by the fact that `use' is executed at compile time. At which time Perl doesn't know anything about threads yet. However, some modules, specifically the ones that are (partly) implemented in XS, do not (yet) survive the cloning process that is involved with creating threads. So you can only use these modules inside threads only. But if you `use' a module, it will be read in at compile time. Of course, a `use' is nothing more than a `require' followed by a call to the "import" class routine (if available). But that doesn't feel natural to do. So this module allows you to use the `useit' (for use in threads command to indicate that a module should only be used inside a thread. For example: suppose you only need the `PerlIO::gzip' module inside a thread: use Thread::Use; # can be anywhere in your program threads->new( \&zipfile,filename,contents ); # start the thread sub zipfile { useit PerlIO::gzip; # only use inside this thread open( my $out,'>:gzip', $_[0] ) or die "$_[0]: $!"; print $out $_[1]; close( $out ); } For completeness, it is also possible to pass any parameters as you would with the `use' command. So: sub storable { useit Storable qw(freeze); # export "freeze" to namespace of thread my $frozen = freeze( \@_ ); } or to use the opposite `no' equivalent; sub warnings { useit warnings "all"; # special code noit warnings "all"; } # # This package was generated automatically with the cpan2rpm # utility. To get this software or for more information # please visit: http://perl.arix.com/ # %prep %setup -q -n %{pkgname}-%{version} chmod -R u+w %{_builddir}/%{pkgname}-%{version} %build grep -rsl '^#!.*perl' . | grep -v '.bak$' |xargs --no-run-if-empty \ %__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)' CFLAGS="$RPM_OPT_FLAGS" %{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '` %{__make} %if %maketest %{__make} test %endif %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %{makeinstall} `%{__perl} -MExtUtils::MakeMaker -e ' print \$ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=%{buildroot}%{_prefix}| : qq|DESTDIR=%{buildroot}| '` cmd=/usr/share/spec-helper/compress_files [ -x $cmd ] || cmd=/usr/lib/rpm/brp-compress [ -x $cmd ] && $cmd # SuSE Linux if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ] then %{__mkdir_p} %{buildroot}/var/adm/perl-modules %{__cat} `find %{buildroot} -name "perllocal.pod"` \ | %{__sed} -e s+%{buildroot}++g \ > %{buildroot}/var/adm/perl-modules/%{name} fi # remove special files find %{buildroot} -name "perllocal.pod" \ -o -name ".packlist" \ -o -name "*.bs" \ |xargs -i rm -f {} # no empty directories find %{buildroot}%{_prefix} \ -type d -depth \ -exec rmdir {} \; 2>/dev/null %{__perl} -MFile::Find -le ' find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}"); print "%doc TODO README"; for my $x (sort @dirs, @files) { push @ret, $x unless indirs($x); } print join "\n", sort @ret; sub wanted { return if /auto$/; local $_ = $File::Find::name; my $f = $_; s|^\Q%{buildroot}\E||; return unless length; return $files[@files] = $_ if -f $f; $d = $_; /\Q$d\E/ && return for reverse sort @INC; $d =~ /\Q$_\E/ && return for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|; $dirs[@dirs] = $_; } sub indirs { my $x = shift; $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs; } ' > %filelist [ -z %filelist ] && { echo "ERROR: empty %files listing" exit -1 } %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files -f %filelist %defattr(-,root,root) %changelog * Sun May 9 2010 rpm@janus.arix.com - Initial build.