threads::shared

Perl extension for sharing data structures between threads
Download

threads::shared Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jerry D. Hedden
  • Publisher web site:
  • http://search.cpan.org/~jdhedden/

threads::shared Tags


threads::shared Description

Perl extension for sharing data structures between threads By default, variables are private to each thread, and each newly created thread gets a private copy of each existing variable. This module allows you to share variables across different threads (and pseudo-forks on Win32). It is used together with the threads module.threads::shared is a Perl module that supports the sharing of the following data types only: scalars and scalar refs, arrays and array refs, and hashes and hash refs.SYNOPSIS use threads; use threads::shared; my $var :shared; my %hsh :shared; my @ary :shared; my ($scalar, @array, %hash); share($scalar); share(@array); share(%hash); $var = $scalar_value; $var = $shared_ref_value; $var = shared_clone($non_shared_ref_value); $var = shared_clone({'foo' => }); $hsh{'foo'} = $scalar_value; $hsh{'bar'} = $shared_ref_value; $hsh{'baz'} = shared_clone($non_shared_ref_value); $hsh{'quz'} = shared_clone(); $ary = $scalar_value; $ary = $shared_ref_value; $ary = shared_clone($non_shared_ref_value); $ary = shared_clone( ]); { lock(%hash); ... } cond_wait($scalar); cond_timedwait($scalar, time() + 30); cond_broadcast(@array); cond_signal(%hash); my $lockvar :shared; # condition var != lock var cond_wait($var, $lockvar); cond_timedwait($var, time()+30, $lockvar); Requirements: · Perl


threads::shared Related Software