Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

blessing support in new threads::shared ?

by renodino (Curate)
on Feb 25, 2006 at 23:22 UTC ( #532820=perlquestion: print w/replies, xml ) Need Help??
renodino has asked for the wisdom of the Perl Monks concerning the following question:

While skimming 5.8.8 perldelta, a remark about a "better threads::shared available on CPAN" caught my eye, so off I went to investigate.

Alas, the Changes file doesn't seem to have any mentions of diffs between 0.95 (the CPAN version) and 0.94 (the version in 5.8.8). However, this little tidbit piqued my curiousity:

0.94 Tue Jan 10 00:00:00 2006 - Initial release to CPAN - 'bless' is now supported on shared refs
Since I've been blissfully blessing shared objects for several releases (IIRC, at least since 5.8.3), I'm confused about what the above note refers to ? Does this mean that blessed shared objects now keep their blessing when passed to another thread ?

Also, can anyone elaborate on the other changes in 0.95 that make it "better" than 0.94 ?

Replies are listed 'Best First'.
Re: blessing support in new threads::shared ?
by dave_the_m (Prior) on Feb 26, 2006 at 12:00 UTC
    It refers to the following bug:
    my $sobj : shared; my $sref = \do{ my $x }; share($sref); $sobj = $sref; bless $sobj, 'baz'; print ref $sobj, "\n"; $ perl587t /tmp/ SCALAR $ perl588t /tmp/ baz
    But the main reason for a separate CPAN release was that I rewrote the threads::shared code to make it faster and use less memory; but that this change was too big to be integrated into 5.8.8


      Ah. I tend to use isa(), so I've not hit that yet.

      And while I've got your attention...

      Might you be persuaded to make threads::shared::_id() (or something similar) a public method ? When marshalling structures/objects between threads, its nice to be able to test if something is already shared, and just pop it into a queue, rather than (de/re)constructing. I'm currently using _id(), but using an obviously private method makes me nervous.

        I'm working on an update to threads::shared right now. There will be only minor changes: An update to ppport.h and improvements in the docs (notably information regarding the use of bless with shared variables). I'll add an exported function called 'is_shared' that will be an alias to '_id'. That should make it formal enough.

        I, too, used '_id' to test for sharing in the Object::InsideOut module, so I see this as a good addition to the module.

        Update: Uploaded to CPAN on 2006-02-27.

        Remember: There's always one more bug.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://532820]
Approved by GrandFather
Front-paged by grinder
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2017-06-23 04:13 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (533 votes). Check out past polls.