[Ace-users] [ace-users] When an Ace_Reactor calls handle_timeout() on an Ace_Event_Handler, is it possible to, within the handle_timeout() call, get at the timer_id that is associated with that particular invocation?

Marc Novakouski mnovakouski at gmail.com
Thu Feb 7 21:01:37 CST 2008


    ACE VERSION: 5.6.2

    HOST MACHINE and OPERATING SYSTEM:
        Not Available at the moment (sorry)/Red Hat 4

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
    COMPILER NAME AND VERSION (AND PATCHLEVEL): Not Available at the moment 
(sorry)

    THE $ACE_ROOT/ace/config.h FILE: Not Available at the moment (sorry)

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE: Not 
Available at the moment (sorry)

    CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
    (used by MPC when you generate your own makefiles): Not Available at the 
moment (sorry)

    AREA/CLASS/EXAMPLE AFFECTED:
        Ace_Reactor/Ace_Event_Handler.  Nothing failed to compile, just 
trying to figure out how to do something.
    DOES THE PROBLEM AFFECT:
        COMPILATION? No.
        LINKING?
        EXECUTION?  Yes.
        OTHER (please specify)?

    SYNOPSIS:
        I'm trying to get access to the timer_id value created when a 
schedule_timer() method is called
from within the handle_timeout() call that results, but can't figure out 
how.

    DESCRIPTION:
        Hi all, ACE newbie here.  Sorry if this has been discussed, I 
searched and couldn't find anything.  Basically,
what I have is a message passing program that wants to read messages from an 
input socket and send them out an output socket.
The only tricky part is that I want to either delay (for a set amount of 
time), or pause entirely, the sending of certain types of messages.
My design was to have a first reactor that reads the input socket, checks 
the incoming messages, and passes them on to a second
reactor via the schedule_timer() method.  If the messages are to be sent 
immediately, I send it with a zero timeout value.  If they are to
be delayed, I send them with the appropriate delay value.  The message 
content is passed within the act argument of the call, ensuring
the appropriate message is associated with the appropriate event.

The problem I have is that I also want to be able to change the delays of 
certain messages on the fly.  That means if messages of type 1
are to be delayed for 1 minute, but during that second the user decides to 
change the delay to 5 seconds, I need to update the delay on
the existing timer events that have already been sent for that message type. 
My solution was this was to manually maintain the set of timer_id
values that result from the schedule_timer() call, and upon a request for a 
change just call the reschedule method for active timer_id values
associated with that message type.  However, I need a way to then remove 
timer_id values from this manually maintained set, and that's
where my question comes in.  Is there a way to get at the timer_id 
associated with a particular handle_timeout() call, from within the
handle_timeout() call itself (or even the add_/remove_reference() calls)?

I'm a little surprised that I haven't yet found an easy way to do this 
because intuitively, if we are given access to the timer_id values and
methods to manipulate their events, a relatively common approach would be to 
save them into some sort of pool, process them when needed,
and then remove them from the pool when handle_timeout() is called and they 
are no longer needed.  I'm guessing that I'm just not seeing
the set of calls I would need to do to do this.

Any help anyone could offer would be much appreciated, including alternative 
designs (which I already have, I just like mine better, so
I'm trying to find a way to make it work).

Thanks,
Marc Novakouski 




More information about the Ace-users mailing list