in reply to Re: Is this a job for a fork?
in thread Is this a job for a fork?

This is exactly what I'm looking for thundergnat. Awesome thank you!!!

Many thanks also to BrowserUk for his threads solution too.

This work is actually part of some software I'm hoping to publish in a scientific journal so I'll be sure to acknowledge you both.

Also thanks to JavaFan for the fork pseudocode and thomas11 for his suggestion too

This site has never failed me. The monks have been taking their genius pills. Good monks.

Cheers

Rich

Replies are listed 'Best First'.
Re^3: Is this a job for a fork?
by BrowserUk (Patriarch) on Jul 13, 2010 at 09:47 UTC

    Be aware. Whilst thundergnat's solution works, creating a new thread for every pairing is expensive (assuming there will be thousands of pairings). The Queue solution avoids this by re-using the threads


    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.

      OK. Thank you BrowserUK. I think that once I've familiarised myself with threads my eventual solution will be a combo of yours and thundergnat's so I'll definitely keep this in mind.

      Many thanks again

        Actually guys, I wonder if I could borrow your brains again. I'm happy to start a new thread if needs be but this is relevant to my previous query.

        I didn't realise that sharing hashes would be different from sharing more complex data structures like a hash of hashes.

        At the point of making a change to the shared object, is there a way of doing the following:

        In thundergnat's code above:

        # this $count{$param1} = $param1 * $param2; # to this for example $count{$param1}{$param2}{'count'} = $param1 * $param2;

        Or in BrowserUk's code above:

        # this ++$hashref->{ $key }; # to this for example ++$hashref->{ $key }->{'count'}

        Is it possible to get around this apparent limitation in threads::shared as stipulated in their docs?

        Once again I very much appreciate any help you can give me

        Cheers,

        Rich