ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Musing on registerable event handlers for some specific events
by Adam Kennedy other posts by this author
Jun 8 2005 11:41AM messages near this date
Re: caller and want | Re: Musing on registerable event handlers for some specific events
With my occasionally-stated preference for keeping the Perl 6 core 
slimmer than it already is, I feel a little silly about suggesting new 
features for P6, but I'd like to stimulate debate on one that I'd like 
to see.

Last year I was having some issues with a large web application that 
needed to run as both a CGI and mod_perl application.

In particular, I wanted an effect where modules that I didn't need for 
every call weren't loaded unless "appropriate".

Now for CGI that means run-time loading. We have a number of these, from 
AutoLoader to (my) Class::Autouse module.

In mod_perl or other forking scenarios these same modules should be 
preloaded BEFORE the fork, so that they only use memory once, not many 
times.

Although Class::Autouse already magically supported mod_perl and 
preloaded, it was obvious that this was the wrong approach. There needed 
to be a way to preload for ALL forking scenarios without duplicating 
logic all over the place.

As a result, I ended up creating prefork.pm to allow different modules 
to register callbacks that would be triggered just before forking, so 
that various run-time loading hooks could all be triggered and loaded 
automatically before the fork.

This has worked for me quite well, but is a voluntary situation in which 
any forking module has to trigger the prefork logic manually.

What I'd like to see for Perl 6 (and I'm not sure if this exists 
already), is some sort of minimal event manager.

The number of events I'm talking about would be extremely low, pre and 
post fork being one. I'm not sure about others, but again I'm imagining 
only events that matter process-wide.

I'd like to see the Perl 6 fork() command issue event triggers to some 
officially blessed event manager module. Any number of other modules 
could register callbacks for whichever events they liked.

The other alternative is to have the event manager overwrite the core 
fork() function... and I dislike this sort of hackery as these tricks 
generally only work if one person does it.

If it can be done in less than 10 lines lines of code, to get the most 
minimal hooks into the core, I'd like to see it done.

Thoughts?

Adam K
Thread:
Adam Kennedy
Juerd
Larry Wall
Adam Kennedy
Gaal Yahas
Adam Kennedy
Larry Wall

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved