I am trying to add a timeout option to PoCoC::UserAgent,
but I couldn't find an official way to implement timeouts
in POE. The problem with the obvious delay/alarm solution
is that there is no alarm_remove method. I hacked one up
as shown below, but I'd like to know if there is any
other way that I missed.

Kirill


# 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;
}

Reply via email to