Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^6: Cloning shared hashref

by jwba (Novice)
on Mar 17, 2011 at 19:05 UTC ( [id://893835]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Cloning shared hashref
in thread Cloning shared hashref

Sure. I was running some functions in separate threads, returning graph-like structures (feature annotations of genome data), e.g.

my $gene = { lots => 'of', data => 'entries' }; my $transcript = { 'even' => 'more', data => 'entries', gene => $gene +}; $gene->{transcript} = [ $transcript ];

I put everything in a result queue of type Thread::Queue. I dequeue and freeze the results to a YAML file after the program finishes, so that I don't have to calculate everything again and again. Unfortunately, Thread::Queue does a shared_clone on everything one throws at it.

This fact leads to the mentioned 'program requirements':

  1. Handle circular references
  2. Save some space with reusing references
I hope this answers your question.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2024-04-23 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found