Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: How to share complex data structure in threads ?

by BrowserUk (Pope)
on Dec 30, 2012 at 07:51 UTC ( #1010901=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    push @s, &share( { $cmd => time } }; ## The & before share() is import
    +ant here; and one of the few times you should ever use it.
    
    ...
    
    my %hash : shared = ( $cmd => time() );
    push @s, \%hash;
    
  2. or download this
    my @array : shared;
    $array[ 0 ] = 'fred'; ## ok
    ...
    my %hash : shared = ( 'a' .. 'z' );
    $array[ 3 ] = \%hash; ## OK
    ...
    
  3. or download this
    lock @s;
    push @s, &share( { $cmd => time() } ); 
    ...
    ...
    lock %{ $s[ 9 ] };
    $s[ 9 ]{ $cmd } = $newtime;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010901]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-12-17 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (38 votes), past polls