Loop-specific

A possible solution to the /Problem with the clock.

Some event libraries already solve this problem and handle alarms and delays appropriately. The POE::Loop API could be extended to expose these mechanisms. The POE kernel would use them where possible, falling back to /POSIX::RT::Timer or the current implementation where not.

I'm thinking something fairly fine grained. Delay for X seconds would set up delay that would call the event, then loop for any new due events. No entry would be created in the POE::Queue for this event. Same would happen with alarms.

[POE::Loop::EV]

Problems

The semantics of delays and alarms might be different for each event library. For instance, POE documentation states that delays and alarms in the past with a negative number will be delivered before any due event. In other words, D1 will be handled before P1 in the following example.

   $poe_kernel->yield( 'P1' );
   $poe_kernel->delay( D1 => -3 );

POE also guarantees the order of alarm delivery. In the following example, A1 will be delivered before A2.

   my $when = time;
   $poe_kernel->delay_add( A1 => $when );
   $poe_kernel->delay_add( A2 => $when );