Date: | Sun, 9 May 2004 11:49:12 -0400 |
From: | Rocco Caputo <rcaputo [...] pobox.com> |
To: | bug-POE [...] rt.cpan.org |
Subject: | early vs. late resource initialization |
POE resources are initialized very early. It happens during
POE::Kernel construction, which comes at C<use POE> time. Part of the
initialization involves setting up signal handlers. This is going
away soon, but it illustrates a potentially widespread problem with
POE's initialization.
Other modules loaded after POE may rely on certain %SIG behaviors.
They may set various signal handlers themselves or "helpfully" set
them to DEFAULT. In doing so, they clobber the %SIG watchers POE has
set up.
Randal suggested moving signal initialization to run() time. I
pointed out that it would break (or at least make inconsistent) the
current resource initialization plan. Nevertheless, the signal
problem sets precedent for the need for late resource initialization.
It was pointed out that early initialization is vital for certain
resources. $poe_kernel methods can be called before run(), so data
structures must be prepared for use before that.
The most obvious solution seems to be breaking POE::Resource
initialization into early and late phases. The early phases run at
load time, to prepare for pre-run() calls, and the late phases
initialize underlying system things (like signal handlers, maybe
threads or something) so they'll run properly.
This message relates to internal implementation. No user-serviceable
APIs are harmed in its making, so I bypassed the mailing list.
-- Rocco Caputo