Re: --skeleton_impl question



On Fri, 2003-05-23 at 11:37, Frank Rehberger wrote:
> Jules Colding wrote:
> 
> >Hi,
> >
> >I have a question regarding the skeleton implementation of *_create().
> >The skeleton code makes the servant keep a reference to the parent poa
> >by doing something like:
> >
> >   newservant->poa = poa;
> >
> >Wouldn't it be more correct to do:
> >
> >  newservant->poa = (PortableServer_POA) CORBA_Object_duplicate((CORBA_Object)poa, ev);
> >  
> >
> good point.
> 
> But, the new servant is created in context of poa, so poa will reference 
> the object allready. Now, if servant increments counter of poa, this 
> would lead to a cyclic referencing between poa and servant. Cyclic 
> referencing should be avoided, isn't it?
> 
> What do you think?
> 

Hmm..  I think, after thinking a bit about this, that the generated code
is correct (but not pretty). The reason is that I only have one POA, the
root POA, and that all of my POA references essentially are of the _ptr
type and that release() is nowhere invoked on any POA reference.

If, OTOH, I had a created a _var typed POA (or a _ptr typed POA) in
another function, and passed that POA to my objects constructor (with
the intend of keeping a local copy), then I would have needed
duplicate() to prevent the new POA from getting destroyed when the
"original" POA goes out of scope (or when release() was called on it),
back in the function where it was created.

Right?

To sum it up - I think that I should use duplicate() in the code snippet
above on my root POA reference and then explicitly release() the
reference in the destructor.


-- 
  jules




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]