On 3 May 2012 05:16, Jianshi Huang <jianshi.huang@...> wrote:
> Overkill? Any idea what level of convenience can we provide? What's
> your idea of the implementation?
Dunno. Haven't thought about the implementation yet, really. I think
I'd like to sort out thread local variable definitions generally first
-- as in Faré's patch, or as discussed way-back-when with Gabor &al.
The question of overkill also applies to *BEFORE/AFTER- hooks.
Managing global resources after all threads have shut down is a valid
use-case for *AFTER-, I think. Yet in absence of *AFTER- anyone
wanting to do that has to use plain *EXIT-HOOKS* instead, which means
the same exit hook has to be responsible for shutting down threads.
For /applications/ this means people cannot skirt their responsibility
to shut down threads so easily -- but for /libraries/ it means that
things do not compose properly.
*BEFORE- hook seems mostly unnecessary, really. Only use-case I can
imagine for it would be trying to debug "who the hell is calling
exit?", but there are other --and better-- tools for that. At the same
time, having only *EXIT-HOOKS* and *AFTER-EXIT-HOOKS* seems mildly
confusing, not to mention lopsided.
The more I think of this, the more I think having both is /right/,
because one is the place libraries spawning threads can push their own
hooks to shut them down, and the other is the place where libraries
having eg. open streams can close them after they're no longer used.
Yet at the same time I'm somewhat skeptical.
The current portability meme seems to mean these hooks would just go
unused, and as long as we're talking about applications and not
libraries, a single function in *EXIT-HOOKS* should be enough to deal
with everything: first shut down threads, then clean up global stuff.
The EXIT stuff mostly happened because I wanted to add EXIT to
Madeira, and only then realized how shoddy QUIT was. Portably,
MADEIRA:EXIT can just about promise to call a bunch of hooks and
exit(3), but even unwinding the current thread is probably more than
it can promise. :/