Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Threads and object access

by Nitrox (Chaplain)
on Dec 11, 2002 at 19:39 UTC ( #219157=note: print w/replies, xml ) Need Help??

in reply to Threads and object access

Fever, I've already tried that route but unfortunately threads::shared doesn't support bless'd items.

Using the second option:

use threads::shared; $HS = new Something(); share($HS);
Causes the reference to become fubar'd:

$VAR1 = \bless( {}, 'Win32::OLE' );


Replies are listed 'Best First'.
Re: Re: Threads and object access
by djantzen (Priest) on Dec 11, 2002 at 19:50 UTC

    Ah, now I see it under the "Bugs" section in the docs: "bless is not supported on shared references. In the current version, bless will only bless the thread local reference and the blessing will not propagate to the other threads. This is expected to be implemented in a future version of Perl."

    What happens if you manually (re)bless the reference in each of the threads? Of course this is contingent upon it being possible that the reference itself (e.g., your Win32::OLE=HASH(0x437c94c)) can be shared, even though it is no longer associated with the package Win32::OLE.

    Update: I think I misunderstood the bug report. I believe it's referring to blessing after the variable has been created and shared; hence the phrase "blessing will not propagate". In some test code I'm successfully sharing blessed objects between threads, so I don't know why your Win32::OLE object is getting wiped out when you share it. How about posting some code?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2023-06-04 05:13 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (17 votes). Check out past polls.