Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^4: Threads and fork and CLONE, oh my!

by xdg (Monsignor)
on Aug 17, 2005 at 15:40 UTC ( #484475=note: print w/replies, xml ) Need Help??

in reply to Re^3: Threads and fork and CLONE, oh my!
in thread Threads and fork and CLONE, oh my!

I sort of meant that tongue-in-cheek... but the benchmarks are neat to see. Actually I mean 'cheap' to use $self as opposed to some other "guaranteed" unique ID like a UUID (e.g. Data::UUID). I suspect that any of the $self as index variations will be faster than a UUID-as-index variation.

I've also pondered a lighter-weight, pure-perl alternative like packing Time::HiRes::gettimeofday() and the memory address of an anoymous lexical during construction, as a memory address at a point in time should be unique on a single machine and "global" uniqueness isn't so much an issue for this kind of object ID.

On the other hand, I'm personally moving away from the unique ID answer as CLONE works for those few who dare to muck with threads, and I don't think the performance hit of sharing objects across threads for those few people who might want it is going to be worth giving up the promiscuous nature of inside-out objects as a general property.

(And for the next headache/magic-trick I'm considering with Object::LocalVars: trying out lexical closures to anonymous globrefs instead of package globals for storage to give local aliasing and encapsulation. And then see if I can get it running without too much of a performance hit against other options. Sign me up for The Perl Crackpot Index, I guess.)


Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re^4: Threads and fork and CLONE, oh my!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-05-27 15:18 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (95 votes). Check out past polls.