01-05-25 18.18, skrev Kirill p� [EMAIL PROTECTED] f�ljande:

> Sorry I wasn't too clear in my initial message.
> 
> The problem is that, because the component is designed to handle
> multiple requests in parallel, I set an alarm for each request,
> and then, when there is an I/O activity, I need to remove the
> alarm set for the particular request where the I/O activity has
> happened and add a new alarm, and when a request completes,
> remove the alarm set for that particular request.
> 
> So there could be a number of solutions:
> 
> (a) Create a new session for each incoming request. Hope not.
>

Why is this so bad?

> (b) Whenever an alarm needs to be removed, remove all alarms
> and requeue all of them except that one. queue_peek_alarms is
> not of use here, because it returns event names only, which
> are all the same, but even if it was it would still be ugly
> as hell. Basically this solution implies my keeping an array
> of pending alarms and requeuing them all whenever any activity
> happens on any of the pending requests.

Yes I agree this solutions sucks.
 
> (c) Have a way to remove a single pending alarm. For that some
> kind of alarm ID would be needed, along with an alarm_remove
> kernel method that would take an alarm ID. The code I posted
> in a previous message appears to work, except occasionally it
> complains about an uninitialized value in the != comparison,
> which right now I have no idea why it happens.

This is rather trivially implmented by a module so I see no real reason for
it to go into Kernel.pm

Why not write PoCo::Cron that does it, a nifty use of weakrefs and alarm
objects would provide a neat and clean interface to this.
 
> # code goes to Kernel.pm
> 
> # to be called by client right after adding an alarm
> sub last_seqnum
> {
> return $queue_seqnum;
> }
> 
> # pass an alarm's seqnum to kill it
> sub alarm_remove
> {
> my $seqnum = shift;
> $seqnum = shift if ref $seqnum;
> my $index = 0;
> $index ++ while $index < @kr_alarms and $kr_alarms[$index]->[ST_SEQ] !=
> $seqnum;
> return unless $index < @kr_alarms;
> {% ses_refcount_dec2 $kr_alarms[$index]->[ST_SESSION], SS_ALCOUNT %}
> splice @kr_alarms, $index, 1;
> warn "Alarm #$seqnum removed\n" if TRACE_EVENTS;
> }

That looks possible super slow for a large amount of alarms.
 
> Kirill
> 
> PS - I'm subscribed to the POE list, so there's no need to CC me.
> 

Ok, most people want them CCed so relevant mail shows up earlier and not
when we get around checking other mail folders.
 

Artur

Reply via email to