Archived

This forum has been archived. Please start a new discussion on GitHub.

Application Shutdown & Ref Counting Classes

Hi,

I've got kind of a follow on to the other thread about application shutdown. Ice::Application provides this nice stuff in the form of CtrlCHandler to shutdown the communicator, destroy the communicator, etc, but as far as I can tell, there are no user hooks - perhaps a user-specified callback to be run when an application shuts down. I also don't see a way to know that the communicator has been shutdown or destroyed? Am I missing something, or is this just a "write your own handler" kind of thing?

My other question is about IceUtil::Shared and Ice::GCShared. The inheritance scheme that I have for an object (subclassed from a slice generated class and subclassed from IceUtil::Thread) means that the derived object inherits from both of the reference counting base classes. This seems to be a "bad thing" since the derived object ends up with ambiguous reference counting functions (reported when trying to instantiate a Ptr). Does anyone have any advice on dealing with this situation, other than "don't do it"?

Thanks,

Comments

  • The IceUtil::CtrlCHandler doesn't know anything about communicators or even about Ice. It is simply a utility provided in the IceUtil library for C++. You have to write your own handler using the IceUtil::CtrlCHandler utility, similar to what Ice::Application is doing. The only purpose of CtrlCHandler is to provide a cross-platform abstraction for signal handling.

    As for your other question, you must not derive servant classes from IceUtil::Shared, because these already derive from IceInternal::GCShared (there is no Ice::GCShared, only an internal class IceInternal::GCShared). Have a look at this FAQ that discusses a special case of this issue.
  • acbell wrote: »
    I also don't see a way to know that the communicator has been shutdown or destroyed? Am I missing something, or is this just a "write your own handler" kind of thing?

    I asked a similar question a little while ago, and the ultimate solution for me was to spawn a separate thread (nb: Ice comes with its own thread library, which took me a little while to come across!) that calls waitForShutdown() and then sets a boolean flag that my main thread checks. This forum post is where Benoit made the suggestion.

    MEF
  • Thanks,

    Right now, I think that all that is built-in is code to shutdown or destroy the communicator. In my mind, it would be kind of nice to provide a user callback as an arg when setting any of these CtrlC handlers through the provided functions in Ice::Application that can run before/after communicator shutdown.

    I ended up just waiting for everything on dtor of the object I have subclassed from Ice::Application. Seems to work OK.

    Thanks again for the idea.