On Thu, Jan 13, 2005 at 04:59:17PM +0300, Sergey Skvortsov wrote:
> Hi.
> 
> I plan write POE::Queue::* in XS and have some questions.
> 
> 1. Can I rely on assumption that $priority and $delta are UV (unsigned int)?
> As I see POE uses timestamps as priority in queues.
> Using "int" instead "double" can help to reach much better performance.

We can limit POE::Queue::* priorities and deltas to integers.  That
significantly reduces the number of priority levels we can have, but
four billion of them should be enough for anybody. :)

> 2. Is $payload always a ref to something?

POE::Queue is designed so it knows nothing about payloads.  All it can
assume is that they're scalars.

> 3. Can filter change $payload on call?
> 
> If not, I think safe to use SV address of $payload as its $id.
> Technically if payload may be contained in the one and only one queue - 
> this greatly simplifies any queue's implementation.
> Of course by nature of SV this $id will be unique at any moment of time 
> - however SV can be reused in the future.

$payload is passed to filters by reference, so they can alter payloads
as a side effect.  If anyone needs the feature, I'd rather add a
map-like method that does it explicitly.

POE's event and alarm IDs are payload IDs in disguise.  Starting them
at 1 and increasing them each time is safer than using memory
addresses.  The monotonic IDs aren't reused as often, so there's less
opportunity to cancel or alter the wrong timer by mistake.

Debugging messages (TRACE_EVENTS, particularly) display event IDs.
The diagnostics would be even more confusing if event IDs repeated
often. :)

> Maybe these questions need to be explained in queue API (POE::Queue)?

I agree.  They did not occur to me while I was writing it.

-- 
Rocco Caputo - http://poe.perl.org/
  • POE::Queue Sergey Skvortsov
    • Re: POE::Queue Rocco Caputo

Reply via email to