On Tue, Jul 30, 2002 at 11:38:56AM +0200, Elizabeth Mattijsen wrote:
> At 01:56 PM 7/29/02 +0200, Arthur Bergman wrote:
> >>At 10:44 AM 7/29/02 +0100, Tim Bunce wrote:
> >>>"Thread::Needs" isn't a very descriptive name - it's too general.
> >>>Something like "Thread::NeedsModules" would be better.
> >I have been thinking maybe it should be called Thread::Modules;
> >use Thread::Modules qw(foo bar baz); #these must be cloned
> >no Thread::Modules qw(don't need this); #these should not be cloned
> 
> Hmmm...  it would be nice if you could mark modules not to be 
> cloned.  Unfortunately, at the current state of things, we can only remove 
> module stashes _after_ they have been cloned ;-(
> 
> Currently the "no Thread::Needs" removes module names from the hash of 
> module names to be kept.
> 
> I basically see two ways of dealing with modules in threads currently: an 
> aggresive way (removing _everything_ except the stuff you specify should 
> stay) and a non-aggresive way (just specifying those modules that you know 
> you don't need).
> 
> The problem with the first is that it may throw away too much.  But you 
> will save the most memory that way.  The problem with the latter is that 
> you only remove the modules of which you _know_ as an author that they're 
> loaded.  But any modules that have been loaded "under the hood" will remain 
> in memory, even if you don't need them.
> 
> I think the two approaches should not reside in the same module.  I would 
> therefore like to suggest the following:  Thread::With and Thread::Without.
> 
> So:
>    Thread::With - mark modules to remain in thread memory
>    Thread::Without - mark modules to be removed from thread memory
> 
> Or maybe we should _interfix_ the word "Module" here?
>    Thread::Module::With - mark modules to remain in thread memory
>    Thread::Module::Without - mark modules to be removed from thread memory
> 
> Or maybe we should _postfix_ the word "Module"?
>    Thread::With::Module - mark modules to remain in thread memory
>    Thread::Without::Module - mark modules to be removed from thread memory
> 
> The "no" calls of these modules would then simply unmark the modules, 
> either for keeping or removing.
> 
> I think that would be a cleaner interface.  Thread::Without would then be 
> for the faint of heart, and Thread::With would be for the more brave and 
> savvy developers...

Or generalize it to focus on the 'at clone time hook' nature:

    Thread::OnClone delete_modules => qw(Foo::Bar Baz);

which could then easily be extended to support other 'at clone time' actions.

But I'm rather uncomfortable with the global impact this module has
(or seems to from the API, I've not looked at the implementation).
It seems likely to cause problems with module that start their own
private threads and may need to use a module that some other module
has declared it's threads don't need. Can't some lexically scoped
implementation be found?

Tim.

Reply via email to