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

Could I ask you to explain the program requirements that led to the need for this routine and its particular feature set?

Replies are listed 'Best First'.
Re^6: Cloning shared hashref
by jwba (Novice) on Mar 17, 2011 at 19:05 UTC

    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.