Archived

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

Servant auto life cycle

Hi guys!

Here is a problem brief:

I have a server side operation:

interface IJobManager
{
IJob* Add( JobItem item ) throws JobException;
....
}

when this method is called by a client I need to create a new servant instance, activate it with an adapter and return a proxy to the client.

Then somehow I need to know that client has destroyed a proxy and no longer need a servant to be active. So I need to destroy my servant instance.
Ice documentation addresses this problem and suggests to use a special method destroy() inside IJobManager interface. Clients are calling destroy() when they no longer need the object.

Question: is there any easier way for clients to use some kind of self-destructing objects. Something like:

class IJobSmartProxy
{
public:

IJobSmartProxy ( const IJobProxy& p ): m_Proxy ( p ) {}
~IJobSmartProxy () { m_Proxy->destroy(); }

private:

IJobProxy m_Proxy;

}

?

Best regards, Leo

Comments