[omniORB] From COM to CORBA...
Stefan Seefeld
seefeld@sympatico.ca
Tue, 27 Feb 2001 21:01:38 -0500
"Len Holgate (Mail List Account)" wrote:
> > Aside from that, I feel that your design is rather ugly. The servant
> > reference count you are accessing is designed for counting references
> > to the _servant_ within the server process, not for counting
>
> Out of interest, since one usually activates the object, lets the POA manage
> it for you and releases the extra reference straight away, under what
> circumstances are these references within the server process ever used for
> much apart from counting the single reference from the POA to the servant?
imagine a container and an iterator, both CORBA objects, but the iterator
accessing the container *servant*. If there wasn't the ability for the iterator
to increase the container servant ref counter, it would risk to lose the container
under its feet. Here is an example:
interface Iterator;
interface Container
{
Iterator first_child();
};
and the implementation:
Iterator_ptr ContainerImpl::first_child()
{
IteratorImpl *iterator = new IteratorImpl(this);
// activate iterator
return iterator->_this();
}
class IteratorImpl : public virtual POA_Iterator
{
public:
IteratorImpl(ContainerImpl *c) : _parent(c) { _parent->_add_ref();}
~IteratorImpl() { _parent->_remove_ref();}
// other methods manipulating the parent
private:
ContainerImpl *_parent;
};
> Agreed. What I'm looking for is how you DO do it if you decide that it IS
> what you need and you happen to be in CORBA-land. Almost all the articles
> and books I've read seem to imply that you just design your way out of the
> problem because reference counting is inherently evil... It seems to me,
> from my COM background, that the only reason that that stance is taken is
> because CORBA can't do it well...
I can only confirm from my experience, that in the sake of scalability, you
should not mandate any particular policy such as ref counting, or the ping.
Depending on the semantics of a particular client / server relationship you
might want to have a ping at a constant interval, or you might want to vary
according to your load, or some entirely different scheme. This kind of
flexibility is what I especially like in the CORBA world.
Best regards, Stefan