Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

getting shared_clone() functionality with earlier threads::shared?

by DrWhy (Chaplain)
on Nov 10, 2010 at 00:59 UTC ( #870454=perlquestion: print w/ replies, xml ) Need Help??
DrWhy has asked for the wisdom of the Perl Monks concerning the following question:

Greeting Monks,

I need to be able to do what threads::shared::shared_clone() does, namely do a deep copy of a data structure except that any portions that are shared are not cloned, but copied into the new structure, maintaining their sharedness with the old structure.

However, I need to do this with slightly older versions of threads::shared. We are working with version 1.14, but this function was added in version 1.21, I believe. It is not practical for us to upgrade at this time, and anyway, I'm considering putting this module up on CPAN and want to minimize the version-dependencies as much as possible.

Is there a solution to this problem that was avaible before the advent of threads::shared::shared_clone()?

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Comment on getting shared_clone() functionality with earlier threads::shared?
Re: getting shared_clone() functionality with earlier threads::shared?
by BrowserUk (Pope) on Nov 10, 2010 at 01:14 UTC
      That's an interesting idea. I hadn't looked at the code for the more recent threads::shared and didn't realize shared_clone was implemented in pure perl -- I assumed it was in .xs like the rest of the module's code.

      Actually, I now think I can solve my problem better using Data::Alias. But I'll have to test to see if this aliasing plays well with shared variables.

      UPDATE: fixed typo.

      --DrWhy

      "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

        Actually, I now think I can solve my problem better using Data::Alias. But I'll have to test to see if this aliasing plays well with shared variables.

        That too is an interesting idea. It's not something I've ever thought to try. My gut feel says it's not going to work, but please be sure to come back and tell us how you get on.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: getting shared_clone() functionality with earlier threads::shared?
by Anonymous Monk on Nov 10, 2010 at 01:17 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-12-19 18:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (91 votes), past polls