At 14:31 -0800 12/4/03, Stas Bekman wrote:
Actually, these are both configurable seperately. You can specify whether all objects have DESTROY called on them (including the cloned ones), or only the original ones. Default is only original ones.
And you can specify a fixup routine for cloned objects. Of which the default is none.
Sounds good. I wonder whether it's safe to assume that if fixup is provided than DESTROY should be called as well for the CLONED objects.
Well, if a cloned object is fixed up (or post_cloned_reconstructed), it seems logical to me it should be DESTROYed as well.
My concern is that a user may provide a fixup method which doesn't allocate the new memory and then we are back to the problem where DESTROY tries to free the same memory block more than once. I think your configurable approach is correct and users should understand why they turn things on or off.
Hmmm... didn't realize you can create blessed objects from XS.
Moreover, I think that's what 99.9% of XS modules do. bless is really a non-XS module thing, and non-XS modules don't need the reconstruction anyway.
No true. I had to jump through these hoops for just about all Thread::xxx modules I made, e.g. Thread::Pool. You don't want the pool destroyed when one of the worker threads exits... ;-)
You are talking about a totally different thing. Reconstruction of the C struct and DESTROY, while related, aren't the same thing ;)
Again, what I was saying is that bless() is normally not used by XS modules. I made no comments regarding DESTROY...
But yes, the actual bookkeeping routine could be made available externally, something like:
Thread::Bless->register( $object );
would that help?
Yes it would.
To enhance its flexibility, you can register any number of objects in a single call.
OK
... In fact I'd suggest to drop the CORE::bless overriding thing altogether as you may interfere with similar overrides.
It honours whatever overrides for CORE::bless existed already. And it makes the general case (which I think just the not DESTROYing of cloned objects) very easy to add: just add:
use Thread::Bless;
to your module's code.
It depends on your definition of "the general case". I think you are a bit biased on this aspect as most of your modules already require 'threads' ;) I doubt it's a general case. A general case is a CPAN module interfacing C structs which should work with and without threads. And which most likely doesn't call bless() anyway.
If you consider that I need to use this module only when I have 5.8.x w/ threads, I can't use() it, but require() it and then figure out what to import. The register things, etc, etc...
Just tell users to call this register method from new(), just after they have blessed the object.
That goes against the principle of least interference. To me, this is really a problem that should be fixed at the system level, e.g. with a pragma.
Well, I'm not very keen on overriding CORE:: functions in the complex systems with multiple modules from different sources (think mod_perl). You override CORE::bless whether I need it or not and it affects all other modules. It'll always call
register( __PACKAGE__,$object );
even for objects which have nothing to do with Thread::Bless. I suppose this is just a bug that needs to be fixed. But you probably weren't aware of it, since you haven't used it with other modules that use bless by themselves, so there could be other side-effects we haven't thought of.
I think instead of overriding CORE::bless, you should optionally import bless into the caller namespace, in which case it won't affect other modules. So your modules will still be simple but call:
use Thread::Bless qw(bless);
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
