Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: bug in threads::shared or is it just me?

by ikegami (Patriarch)
on Apr 05, 2012 at 20:58 UTC ( [id://963738]=note: print w/replies, xml ) Need Help??


in reply to bug in threads::shared or is it just me?

I consider this a bug, and I suspect it's caused by the lack of refcounting of stuff on the stack. This ticket tracks such issues.

Why is that variable shared anyway? It's a sub's variable, so what does that even mean? Furthermore, there's absolutely no reason for that hash to be shared since you return its contents to the parent instead of having the parent access the shared hash. Get rid of needless, weirdly placed :shared and the bug is moot.

Replies are listed 'Best First'.
Re^2: bug in threads::shared or is it just me?
by dada (Chaplain) on Apr 10, 2012 at 15:53 UTC

    well, the example is of course a stripped down test case, just to show the behaviour. in the real world, every thread makes a call to a webservice and writes the result as key/value pair in the hash. the parent of the sub then collects all results and do further processing.

    I can't just remove the :shared, otherwise all data is lost to the parent when a thread ends. sure, I could share one single scalar variable for each thread and compose the hash in the sub, but that's clumsy.

    and anyway, this is not even my code :-) I was just trying to help a friend, and was puzzled about the weird behaviour.

    cheers,
    Aldo

    King of Laziness, Wizard of Impatience, Lord of Hubris

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2026-04-12 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.