Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Dec 30, 2012 at 07:51 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1010901]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-03-28 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found