in reply to adding a hash to a shared object

I am trying to add to my shared variable (`$self`) a reference to an unshared one. How can I share the multilevel hash reference returned by JSON->new->utf8->decode?

Have you looked at threads::shared::shared_clone()?

But, like Corion, I think that most of your difficulties are arising because you are approaching threading your problem from the wrong direction. However, as you have yet to either describe the actual problem in any detail, or post the actual code you are using, we can only give wishy washy answers to your specific questions.

I suspect that if you would describe the overall problem in sufficient detail, there is probably a better way of approaching it that would avoid the problems you are encountering.


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.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: adding a hash to a shared object
by daverave (Scribe) on Aug 11, 2010 at 13:24 UTC
    I suspect that if you would describe the overall problem in sufficient detail, there is probably a better way of approaching it that would avoid the problems you are encountering. I fully agree. Wasn't this enough adding a hash to a shared object?
      Wasn't this enough

      Not really. The only question you ask there is: "How can I share the multilevel hash reference returned by JSON->new->utf8->decode?". Which I answered with a reference to shared_close().

      But that doesn't give us the possibility of suggesting a different approach to achieving your actual goal, rather than just telling you how to implement one small part of your current approach to achieving that goal.

      I'd like to see you post a standalone, single-threaded program with some sample data, that achieves the overall goal. We could then explore the potential for gains through threading, and perhaps, offer an implementation that achieves that, whilst playing to the strengths and avoiding the known weaknesses in the Perl threading model.

      I'm fairly adept with threading in general and ithreads in particular, and I strongly recommend starting from a working single threaded program as a base.


      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.
        You are probably right, the problem is it's quite difficult for me to strip out this piece of code out of its context, which is relatively large. Simply posting the code as-is will do no help (you could not really run it) and adapting it to a form that will be friendly for you is a tedious job (that may come out as I'm too lazy to help you help me but be sure I really appreciate all your help here!)