On Tue, Sep 09, 2003 at 05:42:09PM +0200, Patrick wrote:
> I am new to POE and absolutely fascinated ;-)
>
> I am wondering if an event handler can know at which time it has been
> invoked, ie the time the yield()/post() call was issued, which, depending
> on the activities of other sessions/events/delays/alarms, may be far
> earlier than the time the event will run.
>
> Case in point: logging in a daemon, handled by a specific session.
> There is no big deal if there is a lag between a code wanting to store
> ``something'' in the logfile, and the time the something is written in the
> logfile.
> However, since we put the time in the logfile, it takes more sense to put
> in the logfile the time when the logging was requested than the time at
> which the logging was in fact done.
>
> Of course, it is trivial to pass the current time as an extra argument
> during the yield/post call, which is what I am doing now.
> But I thought that the kernel (have not checked the source) may already
> have this information stored somewhere, and thus may provide access to
> it, such as a CALLER_TIME field since there is already CALLER_{FILE,LINE} or
> anything else.
POE does not track the time a POE::Kernel method is called. However it
does track the time an event is due to be dispatched. For yield() and
post(), that happens to be the method's call time.
The event structure's EV_TIME field is not propagated to event handlers.
While it's fairly simple to implement, the interface change would most
likely break any POE::Session subclasses. That shouldn't be done
lightly.
POE::Session, and all its variants and subclasses, would need to add a
DUE_TIME constant representing where in @_ they will supply events' due
times. They would need to accept the due time as another parameter, and
they would need to pass it on to event handlers at the DUE_TIME offset.
All of POE::Kernel's calls to and definitions of _invoke_state() would
need to be updated accordingly.
The documentation would need patching to include DUE_TIME.
Finally, patches would need to be sent (via
[EMAIL PROTECTED]) to all the CPAN authors with
POE::Session subclasses.
Anyone want to hack POE's guts for fun and fame? :)
--
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/