[Ace-users] [ace-users] ACE_Reactor removeHandler() Etiquitte

Douglas C. Schmidt schmidt at dre.vanderbilt.edu
Tue Nov 20 19:54:42 CST 2007


Hi Steve,

To ensure that we have proper version/platform/compiler information,
please make sure you fill out the appropriate problem report form
(PRF), which is in

$ACE_ROOT/PROBLEM-REPORT-FORM
$TAO_ROOT/PROBLEM-REPORT-FORM

Make sure to include this information when asking any questions about
ACE+TAO since otherwise we have to "guess" what
version/platform/compiler/options you've using, which is very
error-prone and slows down our responsiveness.  If you don't use the
PRF, therefore, it is less likely that someone from the core ACE+TAO
developer team will be able to answer your question.  Naturally, we
encourage and appreciate other members of the ACE+TAO user community
who can respond to questions that they have the answers to.

>In working with a dynamically allocated event handler that inherits
>from ACE_Event_Handler (e.g. a UDP handler),
>is it permissible for the application code to call
>ACE_Reactor::instance()->remove_handler(), at any point, to force
>the ACE_Reactor to remove the event handler from its tables and call
>handle_close()?

Yes, that should be fine.  BTW, are you using Windows or non-Windows?
Likewise, which Reactor implementation are you using?

>Also, what if the call to ACE_Reactor::instance()->remove_handler()
>fails?

This call shouldn't fail unless something totally insane is going on,
e.g., you've already called remove_handler() on the event handler or
you've returned -1 from handle_input(), etc.

>What would be a reasonable cleanup procedure in this case?
>Should I call handle_close() from my application code (which will do
>the `delete this` on the event handler)?

Yes, assuming

1. You allocated the event handler dynamically and

2. You are certain the reactor doesn't have a pointer to your event handler!

BTW, there's more discussion about this in Chapter 3 and 4 of C++NPv2
<www.cs.wustl.edu/~schmidt/ACE/book2/>.

Thanks,

     Doug
-- 
Dr. Douglas C. Schmidt                       Professor and Associate Chair
Electrical Engineering and Computer Science  TEL: (615) 343-8197
Vanderbilt University                        WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203                          NET: d.schmidt at vanderbilt.edu



More information about the Ace-users mailing list